Struct commandcrafter::execute::Execute
source · pub struct Execute;
Implementations§
source§impl Execute
impl Execute
Implement the Execute struct
sourcepub fn run(command: &str, arguments: &[&str]) -> Vec<u8>
pub fn run(command: &str, arguments: &[&str]) -> Vec<u8>
§Execute::run;
this method is used to execute the command and return the output
§Arguments
command
- the name of the commandarguments
- the arguments of the command to be executed
§Returns
the output of the command as a vector of bytes
§Example
use commandcrafter::execute::Execute;
let output = Execute::run("du", &["-h", "--max-depth=1", "."]);
println!("{}", String::from_utf8_lossy(&output));
sourcepub fn print_into_console(output: &[u8])
pub fn print_into_console(output: &[u8])
format method is used to display the output in the console it will be used only when we want to display the output in the console
§Example
use commandcrafter::execute::Execute;
let out = Execute::run("ls", &["-l"]);
let out1 = Execute::run("ping", &["-c", "5", "8.8.8.8"]);
let cmb = &[out, out1].concat();
Execute::print_into_console(cmb);
sourcepub fn write_to_file(content: &[u8]) -> Result<()>
pub fn write_to_file(content: &[u8]) -> Result<()>
§Example
use commandcrafter::execute::Execute;
let out = Execute::run("ls", &["-l"]);
let out1 = Execute::run("ping", &["-c", "5", "8.8.8.8"]);
let cmb = &[out, out1].concat();
let _ = Execute::write_to_file(cmb);
sourcepub fn check_operation(op: &Result<()>) -> bool
pub fn check_operation(op: &Result<()>) -> bool
this module comes to check the existence of the file: ExecuteLog.log
as the existence of the file will show us that the command is executed successfully
Auto Trait Implementations§
impl RefUnwindSafe for Execute
impl Send for Execute
impl Sync for Execute
impl Unpin for Execute
impl UnwindSafe for Execute
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