1use crate::client::{Client, HglibError, Runner};
6use crate::runcommand;
7
8pub struct Arg {}
9
10impl Default for Arg {
11 fn default() -> Self {
12 Self {}
13 }
14}
15
16impl Arg {
17 fn run(&self, client: &mut Client) -> Result<(Vec<u8>, i32), HglibError> {
18 runcommand!(client, "root", &[""])
19 }
20}
21
22impl Client {
23 pub fn root(&mut self, x: Arg) -> Result<String, HglibError> {
24 let (data, _) = x.run(self)?;
25 let pos = data
26 .iter()
27 .rposition(|x| *x != b' ' && *x != b'\n')
28 .map_or(data.len(), |p| p + 1);
29 let data = &data[..pos];
30
31 Ok(String::from_utf8(data.to_vec())?)
32 }
33}