Skip to main content

trellis_testing/
host_status.rs

1use trellis_core::{HostResourceStatus, ResourceKey, Revision, ScopeId, TransactionId};
2
3pub use trellis_core::HostStatusClass;
4
5/// Explicit host status event fed to tests after plan application.
6pub type HostStatusEvent = HostResourceStatus;
7
8/// Recorded classification for a host status event.
9#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct HostStatusRecord {
11    /// Status supplied by the fake host.
12    pub status: HostStatusEvent,
13    /// Deterministic classification assigned by the ledger.
14    pub class: HostStatusClass,
15    /// Last command transaction known for this resource key, if any.
16    pub last_transaction_id: Option<TransactionId>,
17    /// Last command revision known for this resource key, if any.
18    pub last_command_revision: Option<Revision>,
19}
20
21#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
22pub(crate) struct HostStatusIdentity {
23    resource_key: ResourceKey,
24    scope: ScopeId,
25    command_revision: Revision,
26    status_revision: Revision,
27}
28
29impl From<&HostStatusEvent> for HostStatusIdentity {
30    fn from(status: &HostStatusEvent) -> Self {
31        Self {
32            resource_key: status.resource_key.clone(),
33            scope: status.scope,
34            command_revision: status.command_revision,
35            status_revision: status.status_revision,
36        }
37    }
38}