Add method for fetching string props, fetch version
This commit is contained in:
parent
a3c115a035
commit
86dbd2eaed
15
src/lib.rs
15
src/lib.rs
|
@ -25,11 +25,15 @@ pub async fn identity(port: &mut SerialStream) -> Result<Vec<u8>, Error> {
|
|||
}
|
||||
|
||||
pub async fn author(port: &mut SerialStream) -> Result<String, Error> {
|
||||
Ok(String::from_utf8(get_prop(port, b"author").await?)?)
|
||||
get_string_prop(port, b"author").await
|
||||
}
|
||||
|
||||
pub async fn repo(port: &mut SerialStream) -> Result<String, Error> {
|
||||
Ok(String::from_utf8(get_prop(port, b"repo").await?)?)
|
||||
get_string_prop(port, b"repo").await
|
||||
}
|
||||
|
||||
pub async fn version(port: &mut SerialStream) -> Result<String, Error> {
|
||||
get_string_prop(port, b"version").await
|
||||
}
|
||||
|
||||
pub async fn reset(port: &mut SerialStream) -> Result<(), Error> {
|
||||
|
@ -46,6 +50,13 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_string_prop<Port>(port: &mut Port, prop: &[u8]) -> Result<String, Error>
|
||||
where
|
||||
Port: AsyncRead + AsyncWrite + Unpin,
|
||||
{
|
||||
Ok(String::from_utf8(get_prop(port, prop).await?)?)
|
||||
}
|
||||
|
||||
async fn get_prop<Port>(port: &mut Port, prop: &[u8]) -> Result<Vec<u8>, Error>
|
||||
where
|
||||
Port: AsyncRead + AsyncWrite + Unpin,
|
||||
|
|
Loading…
Reference in a new issue