inbox
Source: crates/lvcs/src/adapter/inbox.rs.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Interest {
pub(crate) participant: ParticipantKey,
pub(crate) patterns: Vec<String>,
}
/// One notification as the shell offers it: its metadata and its content.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Received {
/// What `notifications` lists of it.
pub(crate) notification: Notification,
/// What `notifications.read` returns of it.
pub(crate) content: NotificationContent,
}
/// A candidate notification for one participant.
///
/// Kept only when it names `participant` directly or its address matches
/// the participant's interest, and when its signed `at_ms` lies in
/// [`now_ms` − `BULLETIN_SECS`, `now_ms` + `INBOX_SKEW_MS`].
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Item {
/// The local participant it is offered to.
pub(crate) participant: ParticipantKey,
/// The notification.
pub(crate) received: Received,
/// Its arrival time, which orders listing and expires holds.
pub(crate) now_ms: i64,
}
/// `participant`'s open asks and stale saves at start, from the thread
/// documents and `.lvcs/stale-saves.json`.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Refill {
/// The local participant.
pub(crate) participant: ParticipantKey,
/// Its open asks from the thread documents.
pub(crate) asks: Vec<Received>,
/// Its stale saves from `.lvcs/stale-saves.json`.
pub(crate) stale_saves: Vec<Received>,
/// The shell's clock at start.
pub(crate) now_ms: i64,
}
/// List a participant's notifications.
///
/// Its open ones, then its unread ones, as the module docs order them.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct List {
/// The `notifications` or `track_write` request it answers.
pub(crate) req: RequestId,
/// The participant.
pub(crate) participant: ParticipantKey,
/// Only unread notifications sent at or after this time (every one
/// when `None`).
pub(crate) since: Option<i64>,
/// The most bytes of their JSON listed (no bound when `None`).
pub(crate) max_bytes: Option<u32>,
/// Whether it is a hook's hint (decision 242): after it, every
/// notification the participant holds counts as shown.
pub(crate) hint: bool,
/// The shell's clock when the request came.
pub(crate) now_ms: i64,
}
/// Read the content of `participant`'s notifications `ids` for the
/// `notifications.read` request `req`, marking them read.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Read {
/// The `notifications.read` request it answers.
pub(crate) req: RequestId,
/// The participant.
pub(crate) participant: ParticipantKey,
/// The notification ids to read.
pub(crate) ids: Vec<String>,
/// The shell's clock when the request came.
pub(crate) now_ms: i64,
}
/// A runner's check notice for `participant` (decision 193): a
/// `action_failed` when `failed`, else an `action_succeeded`, on check `check`.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Check {
/// The local participant it names.
pub(crate) participant: ParticipantKey,
/// The check's id, in `ID_ENCODING`.
pub(crate) id: String,
/// Whether it is an `action_failed`.
pub(crate) failed: bool,
/// Its notification, as the `Item` that follows offers it.
pub(crate) notification: Notification,
}
/// `participant`'s own notification `notification`, announced by this
/// daemon and offered to every other local participant (decision 239).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Sent {
/// The local participant that sent it.
pub(crate) participant: ParticipantKey,
/// Its metadata.
pub(crate) notification: Notification,
}
/// List `participant`'s open check streaks for the request `req`.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) struct Checks {
/// The request it answers.
pub(crate) req: RequestId,
/// The participant.
pub(crate) participant: ParticipantKey,
}
/// What the inbox actor asks the shell to do.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub(crate) enum InboxOutput {
/// The answer to `List` `req`: `open` first, then the unread
/// `notifications` that fit, and how many didn't (`omitted`).
Listed {
/// The request.
req: RequestId,
/// The unread notifications not open that fit.
notifications: Vec<Notification>,
/// The open asks and holds.
open: Vec<Notification>,
/// How many unread notifications didn't fit.
omitted: u32,
/// The participant's open check streaks, newest first.
checks: Vec<Notification>,
/// The ids listed, open ones included, that arrived after the
/// participant's last hinting `List` (decision 242).
fresh: Vec<String>,
},
/// The answer to `Checks` `req`: the participant's open check streaks,
/// newest first.
Checked {
/// The request.
req: RequestId,
/// The participant.
participant: ParticipantKey,
/// The open streaks.
checks: Vec<Notification>,
},
/// An `action_failed` opened or replaced `participant`'s streak on a
/// check.
StreakOpened {
/// The participant.
participant: ParticipantKey,
},
/// The answer to `Read` `req`: the content of each named notification
/// held, and the ids not held.
Contents {
/// The request.
req: RequestId,
/// The content of each named notification held, in order.
contents: Vec<NotificationContent>,
/// The ids not held.
missing: Vec<String>,
},
}