pub struct RootShell { /* private fields */ }Expand description
Represents a shell with root privileges.
Implementations§
Source§impl RootShell
Implementation of RootShell
impl RootShell
Implementation of RootShell
pub fn new() -> Option<Self>
pub fn new_custom(super_user_provider: &str, shell: &str) -> Option<Self>
Sourcepub fn execute(&mut self, command: impl AsRef<str>) -> String
pub fn execute(&mut self, command: impl AsRef<str>) -> String
Executes a command in the root shell and returns the output trimmed. Blocks the current thread until the command is finished.
§Parameter
command- The command to execute
§Example
use super_shell::RootShell;
let mut root_shell = RootShell::new().expect("Failed to crate root shell");
assert!(root_shell.execute("echo Hello $USER").trim().eq("Hello root"));Trait Implementations§
Auto Trait Implementations§
impl Freeze for RootShell
impl RefUnwindSafe for RootShell
impl Send for RootShell
impl Sync for RootShell
impl Unpin for RootShell
impl UnwindSafe for RootShell
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more