Home
runx-sdk

runx_sdk::command

Structs §

CommandPlan §

pub struct runx_sdk::command::CommandPlan { /* ... */ }

Implementations §

impl CommandPlan

new

fn new(command: &[String], args: &[String]) -> RunxResult<Self>

Build a plan from a command vector (program + leading args) plus extra args.

Examples

use runx_sdk::command::CommandPlan;
use runx_sdk::error::RunxResult;

# fn main() -> RunxResult<()> {
let plan = CommandPlan::new(&<code title="unresolved intra-doc link">&quot;runx&quot;.into()</code>, &<code title="unresolved intra-doc link">&quot;skill&quot;.into(), &quot;echo&quot;.into()</code>)?;
assert_eq!(plan.program, "runx");
assert_eq!(plan.args, <code title="unresolved intra-doc link">&quot;skill&quot;, &quot;echo&quot;</code>);
assert_eq!(plan.argv(), <code title="unresolved intra-doc link">&quot;runx&quot;, &quot;skill&quot;, &quot;echo&quot;</code>);

// An empty command is rejected.
assert!(CommandPlan::new(&[], &[]).is_err());
# Ok(())
# }
use runx_sdk::command::CommandPlan;
use runx_sdk::error::RunxResult;

let plan = CommandPlan::new(&["runx".into()], &["skill".into(), "echo".into()])?;
assert_eq!(plan.program, "runx");
assert_eq!(plan.args, ["skill", "echo"]);
assert_eq!(plan.argv(), ["runx", "skill", "echo"]);

// An empty command is rejected.
assert!(CommandPlan::new(&[], &[]).is_err());
Run

with_cwd

fn with_cwd(self: Self, cwd: Option<PathBuf>) -> Self

with_env

fn with_env(self: Self, env: BTreeMap<String, String>) -> Self

with_stdin

fn with_stdin(self: Self, stdin: Option<String>) -> Self

argv

fn argv(self: &Self) -> Vec<String>

Trait Implementations §

impl Borrow for CommandPlan

borrow

fn borrow(self: &Self) -> &T

impl BorrowMut for CommandPlan

borrow_mut

fn borrow_mut(self: &mut Self) -> &mut T

impl CloneToUninit for CommandPlan

clone_to_uninit

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl Into for CommandPlan

into

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

impl From for CommandPlan

from

fn from(t: T) -> T

Returns the argument unchanged.

impl TryInto for CommandPlan

Error

try_into

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl TryFrom for CommandPlan

Error

try_from

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl Any for CommandPlan

type_id

fn type_id(self: &Self) -> TypeId

impl ToOwned for CommandPlan

Owned

to_owned

fn to_owned(self: &Self) -> T

clone_into

fn clone_into(self: &Self, target: &mut T)

impl Same for CommandPlan

Output

impl Clone for CommandPlan

clone

fn clone(self: &Self) -> CommandPlan

impl Debug for CommandPlan

impl PartialEq for CommandPlan

eq

fn eq(self: &Self, other: &CommandPlan) -> bool

impl Send for CommandPlan

impl Sync for CommandPlan

impl Freeze for CommandPlan

impl UnsafeUnpin for CommandPlan

impl Unpin for CommandPlan

impl UnwindSafe for CommandPlan

impl RefUnwindSafe for CommandPlan

impl StructuralPartialEq for CommandPlan

impl Eq for CommandPlan

CommandOutput §

pub struct runx_sdk::command::CommandOutput { /* ... */ }

Trait Implementations §

impl Borrow for CommandOutput

borrow

fn borrow(self: &Self) -> &T

impl BorrowMut for CommandOutput

borrow_mut

fn borrow_mut(self: &mut Self) -> &mut T

impl CloneToUninit for CommandOutput

clone_to_uninit

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl Into for CommandOutput

into

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

impl From for CommandOutput

from

fn from(t: T) -> T

Returns the argument unchanged.

impl TryInto for CommandOutput

Error

try_into

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl TryFrom for CommandOutput

Error

try_from

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl Any for CommandOutput

type_id

fn type_id(self: &Self) -> TypeId

impl ToOwned for CommandOutput

Owned

to_owned

fn to_owned(self: &Self) -> T

clone_into

fn clone_into(self: &Self, target: &mut T)

impl Same for CommandOutput

Output

impl Clone for CommandOutput

clone

fn clone(self: &Self) -> CommandOutput

impl Debug for CommandOutput

impl PartialEq for CommandOutput

eq

fn eq(self: &Self, other: &CommandOutput) -> bool

impl Send for CommandOutput

impl Sync for CommandOutput

impl Freeze for CommandOutput

impl UnsafeUnpin for CommandOutput

impl Unpin for CommandOutput

impl UnwindSafe for CommandOutput

impl RefUnwindSafe for CommandOutput

impl StructuralPartialEq for CommandOutput

impl Eq for CommandOutput

Functions §

run_command §

fn run_command(plan: &CommandPlan) -> crate::error::RunxResult<CommandOutput>