Skip to main content

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::ceiling::Ceiling;
17use super::waiting::Exit;
18
19/// What the short window came to. Exhaustive rather than an optional
20/// handle: "it finished" and "it is still going" are two different
21/// things for the caller to say to a model, and a `None` would leave
22/// which one it was to be inferred.
23#[derive(Debug, PartialEq, Eq)]
24pub enum Started {
25    Settled {
26        exit: Exit,
27        stdout: String,
28        stderr: String,
29        /// How the person's memory ceiling fared while it ran; `None` when
30        /// none was asked for or it held unreached (Exec.lean D95).
31        ceiling: Option<Ceiling>,
32    },
33    Backgrounded {
34        id: BacklogId,
35        what: String,
36    },
37}
38
39/// Which of the two kinds of member a standing entry is.
40#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41pub enum BacklogKind {
42    Command,
43    Run,
44}
45
46impl BacklogKind {
47    #[must_use]
48    pub fn as_str(self) -> &'static str {
49        match self {
50            BacklogKind::Command => "command",
51            BacklogKind::Run => "run",
52        }
53    }
54}
55
56/// A member that is still running.
57#[derive(Debug, Clone, PartialEq, Eq)]
58pub struct Standing {
59    pub id: BacklogId,
60    pub scope: Address,
61    pub what: String,
62    pub kind: BacklogKind,
63}
64
65/// A member that has stopped, collected once and then forgotten.
66#[derive(Debug, Clone, PartialEq, Eq)]
67pub struct Finished {
68    pub id: BacklogId,
69    pub what: String,
70    pub exit: Exit,
71    pub stdout: String,
72    pub stderr: String,
73    /// How the person's memory ceiling fared while it ran (Exec.lean D95).
74    pub ceiling: Option<Ceiling>,
75}