pub struct CommandOutput {
pub stdout: String,
pub stderr: String,
pub exit_status: i32,
}Expand description
The output of an executed SSH command.
Contains the standard output, standard error, and exit status of the executed command.
Fields§
§stdout: StringThe standard output from the command.
stderr: StringThe standard error from the command.
exit_status: i32The exit status code of the command. 0 typically indicates success, while non-zero indicates an error.
Implementations§
Source§impl CommandOutput
impl CommandOutput
Sourcepub fn new(stdout: String, stderr: String, exit_status: i32) -> CommandOutput
pub fn new(stdout: String, stderr: String, exit_status: i32) -> CommandOutput
Creates a new CommandOutput instance.
§Arguments
stdout- The standard output from the commandstderr- The standard error from the commandexit_status- The exit status code
§Examples
use lmrc_ssh::CommandOutput;
let output = CommandOutput::new(
"Hello, World!".to_string(),
String::new(),
0
);
assert_eq!(output.stdout, "Hello, World!");
assert!(output.is_success());Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the command executed successfully (exit status 0).
§Examples
use lmrc_ssh::CommandOutput;
let success = CommandOutput::new("output".to_string(), String::new(), 0);
assert!(success.is_success());
let failure = CommandOutput::new(String::new(), "error".to_string(), 1);
assert!(!failure.is_success());Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Returns true if the command failed (non-zero exit status).
§Examples
use lmrc_ssh::CommandOutput;
let output = CommandOutput::new(String::new(), "error".to_string(), 1);
assert!(output.is_failure());Sourcepub fn combined_output(&self) -> String
pub fn combined_output(&self) -> String
Returns the combined output (stdout + stderr).
§Examples
use lmrc_ssh::CommandOutput;
let output = CommandOutput::new(
"line1\n".to_string(),
"error1\n".to_string(),
0
);
assert_eq!(output.combined_output(), "line1\nerror1\n");Trait Implementations§
Source§impl Clone for CommandOutput
impl Clone for CommandOutput
Source§fn clone(&self) -> CommandOutput
fn clone(&self) -> CommandOutput
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CommandOutput
impl Debug for CommandOutput
Source§impl Display for CommandOutput
impl Display for CommandOutput
Source§impl PartialEq for CommandOutput
impl PartialEq for CommandOutput
impl Eq for CommandOutput
impl StructuralPartialEq for CommandOutput
Auto Trait Implementations§
impl Freeze for CommandOutput
impl RefUnwindSafe for CommandOutput
impl Send for CommandOutput
impl Sync for CommandOutput
impl Unpin for CommandOutput
impl UnwindSafe for CommandOutput
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