Skip to content

Commit fa86e4a

Browse files
committed
Make strum optional
1 parent c2ddc0e commit fa86e4a

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

@@ -351,6 +353,7 @@ impl From<CommandType> for TimedOutCommand {
351353
#[derive(Clone, Copy, Debug, Default, Diagnostic, Error, FromRepr)]
352354
#[non_exhaustive]
353355
#[repr(u8)]
356+
#[cfg(feature = "serialpot")]
354357
pub enum RomErrorKind {
355358
#[error("Invalid message received")]
356359
#[diagnostic(code(espflash::rom::invalid_message))]
@@ -426,6 +429,7 @@ pub enum RomErrorKind {
426429
Other = 0xff,
427430
}
428431

432+
#[cfg(feature = "serialpot")]
429433
impl From<u8> for RomErrorKind {
430434
fn from(raw: u8) -> Self {
431435
Self::from_repr(raw).unwrap_or_default()
@@ -435,13 +439,15 @@ impl From<u8> for RomErrorKind {
435439
/// An error originating from a device's ROM functionality
436440
#[derive(Clone, Copy, Debug, Diagnostic, Error)]
437441
#[error("Error while running {command} command")]
442+
#[cfg(feature = "serialpot")]
438443
#[non_exhaustive]
439444
pub struct RomError {
440445
command: CommandType,
441446
#[source]
442447
kind: RomErrorKind,
443448
}
444449

450+
#[cfg(feature = "serialpot")]
445451
impl RomError {
446452
pub fn new(command: CommandType, kind: RomErrorKind) -> RomError {
447453
RomError { command, kind }

0 commit comments

Comments
 (0)