[][src]Struct usereport::command::Command

pub struct Command { /* fields omitted */ }

Run a CLI command and store its stdout.

Example

#[cfg(target_os = "macos")]
let command = Command::new("uname", r#"/usr/bin/uname -a"#)
    .with_title("Host OS")
    .with_timeout(5);
#[cfg(target_os = "linux")]
let command = Command::new("true", r#"/bin/true"#)
    .with_title("Just a successful command")
    .with_timeout(5);
match command.exec() {
    CommandResult::Success {
        command: _,
        run_time_ms: _,
        stdout: stdout,
    } => println!("Command output '{}'", stdout),
    CommandResult::Failed {
        command: _,
        run_time_ms: _,
        stdout: stdout,
    } => println!("Command failed with output '{}'", stdout),
    CommandResult::Timeout {
        command: _,
        run_time_ms: _,
    } => println!("Command timed out"),
    CommandResult::Error {
        command: _,
        reason: reason,
    } => println!("Command errored because {}", reason),
};

Methods

impl Command[src]

pub fn new<T: Into<String>>(name: T, command: T) -> Command[src]

Create new command with default values

pub fn name(&self) -> &str[src]

Get name of command

pub fn command(&self) -> &str[src]

Get command args

pub fn title(&self) -> Option<&str>[src]

Get title of command

pub fn description(&self) -> Option<&str>[src]

Get description of command

pub fn with_title<T: Into<String>>(self, title: T) -> Command[src]

Set title of command

pub fn with_timeout<T: Into<Option<u64>>>(self, timeout_sec: T) -> Command[src]

Set title of command

pub fn with_description<T: Into<String>, S: Into<Option<T>>>(
    self,
    description: S
) -> Command
[src]

Set description of command

Set Links of command

pub fn exec(self) -> CommandResult[src]

Execute this command; may panic

Standard output and error will be written to a temporary file, because a pipe may only contain up 64 KB data; cf. http://man7.org/linux/man-pages/man7/pipe.7.html.

Trait Implementations

impl Clone for Command[src]

impl Debug for Command[src]

impl<'de> Deserialize<'de> for Command[src]

impl Eq for Command[src]

impl PartialEq<Command> for Command[src]

impl Serialize for Command[src]

impl StructuralEq for Command[src]

impl StructuralPartialEq for Command[src]

Auto Trait Implementations

impl RefUnwindSafe for Command

impl Send for Command

impl Sync for Command

impl Unpin for Command

impl UnwindSafe for Command

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,