[−][src]Struct usereport::command::Command
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]
self,
description: S
) -> Command
Set description of command
pub fn with_links<T: Into<Option<Vec<Link>>>>(self, links: T) -> Command
[src]
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]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Eq for Command
[src]
impl PartialEq<Command> for Command
[src]
impl Serialize for Command
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,