Skip to content

Commit

Permalink
Impl FromStr trait for OsdpCapability and OsdpFlag
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
sidcha committed Nov 7, 2023
1 parent 8274517 commit 97397f1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rust/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,19 @@ bitflags::bitflags! {
}
}

impl FromStr for OsdpFlag {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"EnforceSecure" => Ok(OsdpFlag::EnforceSecure),
"InstallMode" => Ok(OsdpFlag::InstallMode),
"IgnoreUnsolicited" => Ok(OsdpFlag::IgnoreUnsolicited),
_ => Err(anyhow::anyhow!("Parse error {s}"))
}
}
}

pub struct PdInfo {
pub name: CString,
pub address: i32,
Expand Down

0 comments on commit 97397f1

Please sign in to comment.