mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-06 22:51:31 +00:00
Initial commit.
This commit is contained in:
23
xsd/src/client.rs
Normal file
23
xsd/src/client.rs
Normal 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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user