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: CommandIdShell-state-local identity.
command_line: StringCommand text stored verbatim; may be empty.
cwd_uri: Option<String>Working-directory URI at start, or None when unknown.
status: CommandStatusCurrent/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: CommandOutputRangeInclusive 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
impl CommandExecution
Sourcepub fn running(
id: CommandId,
command_line: impl Into<String>,
cwd_uri: Option<String>,
start_line: u64,
started_at_ms: Option<u64>,
) -> Self
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());Sourcepub fn finish(
&mut self,
end_line: u64,
exit_code: Option<i32>,
signal: Option<i32>,
ended_at_ms: Option<u64>,
duration_ms: Option<u64>,
)
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
impl Clone for CommandExecution
Source§fn clone(&self) -> CommandExecution
fn clone(&self) -> CommandExecution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more