Skip to content

Commit a44aa31

Browse files
committed
Make strum optional
1 parent 6194c06 commit a44aa31

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

espflash/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ serde = { version = "1.0.196", features = ["derive"] }
5151
serialport = { version = "4.3.0", optional = true }
5252
sha2 = "0.10.8"
5353
slip-codec = { version = "0.4.0", optional = true }
54-
strum = { version = "0.26.1", features = ["derive"] }
54+
strum = { version = "0.26.1", features = ["derive"], optional = true }
5555
thiserror = "1.0.56"
5656
toml = "0.8.10"
5757
update-informer = { version = "1.1.0", optional = true }
@@ -83,7 +83,7 @@ cli = [
8383
]
8484

8585
# enables connecting to a device via serial port
86-
serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex"]
86+
serialport = ["flashing", "dep:serialport", "dep:slip-codec", "dep:regex", "dep:strum"]
8787

8888
# enables flash stubs and stub commands
8989
flashing = ["xmas-elf"]

espflash/src/error.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ use std::{
88
use miette::Diagnostic;
99
#[cfg(feature = "serialport")]
1010
use slip_codec::SlipError;
11-
use strum::{FromRepr, VariantNames};
11+
#[cfg(feature = "serialpot")]
12+
use strum::FromRepr;
1213
use thiserror::Error;
1314

1415
#[cfg(feature = "cli")]
@@ -184,6 +185,7 @@ pub enum Error {
184185
InvalidElf(#[from] ElfError),
185186

186187
#[error("The bootloader returned an error")]
188+
#[cfg(feature = "serialpot")]
187189
#[diagnostic(transparent)]
188190
RomError(#[from] RomError),
189191

@@ -345,6 +347,7 @@ impl From<CommandType> for TimedOutCommand {
345347
#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, FromRepr)]
346348
#[non_exhaustive]
347349
#[repr(u8)]
350+
#[cfg(feature = "serialpot")]
348351
pub enum RomErrorKind {
349352
#[error("Invalid message received")]
350353
#[diagnostic(code(espflash::rom::invalid_message))]
@@ -420,6 +423,7 @@ pub enum RomErrorKind {
420423
Other = 0xff,
421424
}
422425

426+
#[cfg(feature = "serialpot")]
423427
impl From<u8> for RomErrorKind {
424428
fn from(raw: u8) -> Self {
425429
Self::from_repr(raw).unwrap_or_default()
@@ -429,13 +433,15 @@ impl From<u8> for RomErrorKind {
429433
/// An error originating from a device's ROM functionality
430434
#[derive(Clone, Copy, Debug, Diagnostic, Error)]
431435
#[error("Error while running {command} command")]
436+
#[cfg(feature = "serialpot")]
432437
#[non_exhaustive]
433438
pub struct RomError {
434439
command: CommandType,
435440
#[source]
436441
kind: RomErrorKind,
437442
}
438443

444+
#[cfg(feature = "serialpot")]
439445
impl RomError {
440446
pub fn new(command: CommandType, kind: RomErrorKind) -> RomError {
441447
RomError { command, kind }

0 commit comments

Comments
 (0)