pub struct RunId(/* private fields */);Expand description
The identity of one run of an external program
A command can run several programs at the same time, and the lines of those
programs then reach the presenter interleaved. Every ProcessEvent
carries this value so that a consumer can put a line back with the run that
produced it, group the output of one program, and know when that program
ended.
The identity is Clawless’s own, and it counts runs. It is not the
ProcessId that the operating system assigns, which names the program
while it runs and which the operating system reuses afterwards. A run has an
identity before the program starts and keeps it after the program ended,
which is what an event stream needs.
§Examples
use clawless_core::event::process::RunId;
let first = RunId::next();
let second = RunId::next();
assert_ne!(first, second);Implementations§
Source§impl RunId
impl RunId
Sourcepub fn next() -> Self
pub fn next() -> Self
Returns an identity that no earlier call returned
Process::run calls this once per run, so a command that runs a
program does not need it. A test that stands in for a run builds its
events with identities from here.
The counter wraps after 2^64 runs. An application that started a
program every nanosecond would reach that point after more than five
hundred years, so the wrap is not a case that callers handle.
§Examples
use clawless_core::event::process::RunId;
let id = RunId::next();
assert_eq!(id, id);Trait Implementations§
impl Copy for RunId
Source§impl Display for RunId
Shows the identity for a reader
impl Display for RunId
Shows the identity for a reader
The text is the number alone, so that a log line can name the run without
the punctuation that Debug adds.