Struct CommandExecution

Source
pub struct CommandExecution {
    pub id: CommandId,
    pub command_line: String,
    pub cwd_uri: Option<String>,
    pub status: CommandStatus,
    pub exit_code: Option<i32>,
    pub signal: Option<i32>,
    pub started_at_ms: Option<u64>,
    pub ended_at_ms: Option<u64>,
    pub duration_ms: Option<u64>,
    pub output_range: CommandOutputRange,
    pub stdout_range: Option<CommandOutputRange>,
    pub stderr_range: Option<CommandOutputRange>,
}
Expand description

Serializable lifecycle snapshot for one shell command.

Times and durations are milliseconds in a caller-defined clock domain. None means not reported. Public fields/deserialization do not enforce lifecycle, time-order, range, or status/code consistency.

§Examples

use ailloli_ui_terminal_core::{CommandExecution, CommandId, CommandStatus};
let command = CommandExecution::running(CommandId(1), "cargo check", None, 7, Some(100));
assert_eq!((command.status, command.output_range.start_line), (CommandStatus::Running, 7));

Fields§

§id: CommandId

Shell-state-local identity.

§command_line: String

Command text stored verbatim; may be empty.

§cwd_uri: Option<String>

Working-directory URI at start, or None when unknown.

§status: CommandStatus

Current/finished lifecycle status.

§exit_code: Option<i32>

Signed exit code, or None when absent.

§signal: Option<i32>

Signed terminating signal, or None when absent.

§started_at_ms: Option<u64>

Start timestamp in caller-defined milliseconds.

§ended_at_ms: Option<u64>

End timestamp in the same caller-defined clock domain.

§duration_ms: Option<u64>

Duration in milliseconds, supplied or derived with checked subtraction.

§output_range: CommandOutputRange

Inclusive combined-output global line range.

§stdout_range: Option<CommandOutputRange>

Optional stdout range; current helpers mirror combined output here.

§stderr_range: Option<CommandOutputRange>

Optional stderr range; current helpers leave it None.

Implementations§

Source§

impl CommandExecution

Source

pub fn running( id: CommandId, command_line: impl Into<String>, cwd_uri: Option<String>, start_line: u64, started_at_ms: Option<u64>, ) -> Self

Creates a running command with an open combined/stdout range.

Exit/signal/end/duration are cleared and stderr remains untracked. Inputs are stored verbatim, including an empty command or empty CWD string.

§Examples
use ailloli_ui_terminal_core::{CommandExecution, CommandId, CommandStatus};
let command = CommandExecution::running(CommandId(2), "", Some("".into()), 0, None);
assert_eq!(command.status, CommandStatus::Running);
assert!(command.command_line.is_empty() && command.stderr_range.is_none());
Source

pub fn finish( &mut self, end_line: u64, exit_code: Option<i32>, signal: Option<i32>, ended_at_ms: Option<u64>, duration_ms: Option<u64>, )

Finishes this command and closes combined/stdout output ranges.

A signal makes status Interrupted; otherwise exit zero succeeds, nonzero fails, and no code yields Unknown. Explicit duration_ms wins. Without it, duration is ended - started using checked subtraction and is None when either time is absent or end precedes start. The output end clamps to its start; stderr range is not changed.

§Examples
use ailloli_ui_terminal_core::{CommandExecution, CommandId, CommandStatus};
let mut command = CommandExecution::running(CommandId(1), "true", None, 4, Some(100));
command.finish(6, Some(0), None, Some(125), None);
assert_eq!((command.status, command.duration_ms, command.output_range.end_line), (CommandStatus::Succeeded, Some(25), Some(6)));

Trait Implementations§

Source§

impl Clone for CommandExecution

Source§

fn clone(&self) -> CommandExecution

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CommandExecution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CommandExecution

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for CommandExecution

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for CommandExecution

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for CommandExecution

Source§

impl StructuralPartialEq for CommandExecution

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

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

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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