-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #231 from rust-embedded/info
initial "info" tool support
- Loading branch information
Showing
7 changed files
with
87 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use std::str::FromStr; | ||
|
||
use anyhow::Ok; | ||
use svd_rs::Device; | ||
|
||
#[derive(Clone, Debug)] | ||
#[non_exhaustive] | ||
pub enum Request { | ||
DeviceName, | ||
} | ||
|
||
impl FromStr for Request { | ||
type Err = anyhow::Error; | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"device-name" => Ok(Self::DeviceName), | ||
_ => Err(anyhow::anyhow!("Unknown info request: {s}")), | ||
} | ||
} | ||
} | ||
|
||
impl Request { | ||
pub fn process(&self, device: &Device) -> anyhow::Result<String> { | ||
match self { | ||
Self::DeviceName => Ok(device.name.to_string()), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters