Initial commit.

This commit is contained in:
Alex Zenla
2024-01-08 12:43:16 -08:00
commit 710282674a
9 changed files with 328 additions and 0 deletions

23
xsd/src/client.rs Normal file
View File

@ -0,0 +1,23 @@
use crate::bus::{XsdBusError, XsdSocket};
use crate::sys::{XSD_DIRECTORY, XSD_READ};
pub struct XsdClient {
socket: XsdSocket,
}
impl XsdClient {
pub fn new() -> Result<XsdClient, XsdBusError> {
let socket = XsdSocket::dial()?;
Ok(XsdClient { socket })
}
pub fn list(&mut self, path: &str) -> Result<Vec<String>, XsdBusError> {
let response = self.socket.send_single(0, XSD_DIRECTORY, path)?;
Ok(response.parse_string_vec()?)
}
pub fn read(&mut self, path: &str) -> Result<Vec<u8>, XsdBusError> {
let response = self.socket.send_single(0, XSD_READ, path)?;
Ok(response.payload)
}
}