Skip to content

Commit b961a1b

Browse files
committed
Make toml optional
1 parent 0113512 commit b961a1b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cargo-espflash/src/error.rs

+5
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,28 @@ pub enum Error {
6060
}
6161

6262
/// TOML deserialization error
63+
#[cfg(feature = "cli")]
6364
#[derive(Debug)]
6465
pub struct TomlError {
6566
err: toml::de::Error,
6667
source: String,
6768
}
6869

70+
#[cfg(feature = "cli")]
6971
impl TomlError {
7072
pub fn new(err: toml::de::Error, source: String) -> Self {
7173
Self { err, source }
7274
}
7375
}
7476

77+
#[cfg(feature = "cli")]
7578
impl Display for TomlError {
7679
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
7780
write!(f, "Failed to parse toml")
7881
}
7982
}
8083

84+
#[cfg(feature = "cli")]
8185
impl Diagnostic for TomlError {
8286
fn source_code(&self) -> Option<&dyn SourceCode> {
8387
Some(&self.source)
@@ -92,6 +96,7 @@ impl Diagnostic for TomlError {
9296
}
9397

9498
// NOTE: no `source` on purpose to prevent duplicating the message
99+
#[cfg(feature = "cli")]
95100
impl std::error::Error for TomlError {}
96101

97102
/// Unsupported target error

espflash/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ sha2 = "0.10.8"
5353
slip-codec = { version = "0.4.0", optional = true }
5454
strum = { version = "0.26.1", features = ["derive"], optional = true }
5555
thiserror = "1.0.56"
56-
toml = "0.8.10"
56+
toml = { version = "0.8.10", optional = true }
5757
update-informer = { version = "1.1.0", optional = true }
5858
xmas-elf = { version = "0.9.1", optional = true }
5959

@@ -78,6 +78,7 @@ cli = [
7878
"dep:indicatif",
7979
"dep:lazy_static",
8080
"dep:parse_int",
81+
"dep:toml",
8182
"dep:update-informer",
8283
"serialport"
8384
]
@@ -86,4 +87,4 @@ cli = [
8687
serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex", "dep:strum"]
8788

8889
# enables flash stubs and stub commands
89-
flashing = ["xmas-elf"]
90+
flashing = ["xmas-elf", "dep:toml"]

0 commit comments

Comments
 (0)