runtime/backlog/report.rs
1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4// Copyright (c) 2026 2youg1 and the sprawling contributors
5
6//! What the table tells a caller: how a start came out, what is still
7//! running, and what has stopped.
8//!
9//! Four value types and no behaviour. They sit apart from the table
10//! because they are what everything outside this module reads, while
11//! the table is how it is kept (`crates/runtime/spec/Backlog.lean` ยง8-28-1).
12
13use kernel::Address;
14
15use super::BacklogId;
16use super::waiting::Exit;
17
18/// What the short window came to. Exhaustive rather than an optional
19/// handle: "it finished" and "it is still going" are two different
20/// things for the caller to say to a model, and a `None` would leave
21/// which one it was to be inferred.
22#[derive(Debug, PartialEq, Eq)]
23pub enum Started {
24 Settled {
25 exit: Exit,
26 stdout: String,
27 stderr: String,
28 },
29 Backgrounded {
30 id: BacklogId,
31 what: String,
32 },
33}
34
35/// Which of the two kinds of member a standing entry is.
36#[derive(Debug, Clone, Copy, PartialEq, Eq)]
37pub enum BacklogKind {
38 Command,
39 Run,
40}
41
42impl BacklogKind {
43 #[must_use]
44 pub fn as_str(self) -> &'static str {
45 match self {
46 BacklogKind::Command => "command",
47 BacklogKind::Run => "run",
48 }
49 }
50}
51
52/// A member that is still running.
53#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct Standing {
55 pub id: BacklogId,
56 pub scope: Address,
57 pub what: String,
58 pub kind: BacklogKind,
59}
60
61/// A member that has stopped, collected once and then forgotten.
62#[derive(Debug, Clone, PartialEq, Eq)]
63pub struct Finished {
64 pub id: BacklogId,
65 pub what: String,
66 pub exit: Exit,
67 pub stdout: String,
68 pub stderr: String,
69}