Add explicit vocabulary and named operation contexts
This commit is contained in:
+12
-24
@@ -4,8 +4,8 @@ use std::collections::BTreeSet;
|
||||
use std::net::IpAddr;
|
||||
|
||||
use crate::app::{Application, ClientDisplay};
|
||||
use crate::domain::{Client, PublicKey, RuntimeObservation};
|
||||
use crate::runtime::RuntimeObservation as Statistics;
|
||||
use crate::domain::{ApplyStatus, Client, PublicKey};
|
||||
use crate::runtime::RuntimeObservation;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum Screen {
|
||||
@@ -34,13 +34,6 @@ pub enum DialogKind {
|
||||
Exit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum AppliedState {
|
||||
Unknown,
|
||||
Unavailable,
|
||||
Verified,
|
||||
}
|
||||
|
||||
/// Public client values for both states. No configuration bytes or secrets are
|
||||
/// retained in a view snapshot.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
@@ -58,9 +51,9 @@ pub struct SessionView {
|
||||
/// saved bytes can be projected. This includes nonmanaged peers.
|
||||
pub saved_peer_count: Option<usize>,
|
||||
pub document_issues: Vec<crate::wireguard::DocumentIssue>,
|
||||
pub applied: AppliedState,
|
||||
pub applied: ApplyStatus,
|
||||
pub reserved_addresses: BTreeSet<IpAddr>,
|
||||
pub statistics: Statistics,
|
||||
pub statistics: RuntimeObservation,
|
||||
pub has_draft: bool,
|
||||
pub vault_initialized: bool,
|
||||
}
|
||||
@@ -83,11 +76,6 @@ impl SessionView {
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
let applied = match states.applied() {
|
||||
RuntimeObservation::Unknown => AppliedState::Unknown,
|
||||
RuntimeObservation::Unavailable => AppliedState::Unavailable,
|
||||
RuntimeObservation::Verified => AppliedState::Verified,
|
||||
};
|
||||
let projection = app.display_projection();
|
||||
let saved_peer_count =
|
||||
crate::wireguard::ConfigDocument::parse(&app.saved_bytes().server_config)
|
||||
@@ -99,9 +87,9 @@ impl SessionView {
|
||||
client_states,
|
||||
saved_peer_count,
|
||||
document_issues: projection.document_issues,
|
||||
applied,
|
||||
applied: *states.applied(),
|
||||
reserved_addresses: states.reserved_addresses().clone(),
|
||||
statistics: Statistics::unknown(),
|
||||
statistics: RuntimeObservation::unknown(),
|
||||
has_draft: app.has_draft_changes(),
|
||||
vault_initialized: app.vault_initialized(),
|
||||
}
|
||||
@@ -318,7 +306,7 @@ impl UiState {
|
||||
|
||||
/// Apply only statistics sampled from the still-current saved/draft view.
|
||||
/// This never changes the applied-state marker.
|
||||
pub fn apply_statistics(&mut self, generation: u64, statistics: Statistics) -> bool {
|
||||
pub fn apply_statistics(&mut self, generation: u64, statistics: RuntimeObservation) -> bool {
|
||||
if generation != self.generation {
|
||||
return false;
|
||||
}
|
||||
@@ -521,9 +509,9 @@ mod tests {
|
||||
client_states: Default::default(),
|
||||
saved_peer_count: None,
|
||||
document_issues: Vec::new(),
|
||||
applied: AppliedState::Unknown,
|
||||
applied: ApplyStatus::Unknown,
|
||||
reserved_addresses: BTreeSet::new(),
|
||||
statistics: Statistics::unknown(),
|
||||
statistics: RuntimeObservation::unknown(),
|
||||
has_draft: false,
|
||||
vault_initialized: true,
|
||||
}
|
||||
@@ -669,9 +657,9 @@ mod tests {
|
||||
let key = PublicKey::from_bytes([4; 32]);
|
||||
let mut state = UiState::default();
|
||||
assert!(state.apply_view(view(0, vec![row(key, "client", true)])));
|
||||
assert!(state.apply_statistics(0, Statistics::unknown()));
|
||||
assert_eq!(state.view.as_ref().unwrap().applied, AppliedState::Unknown);
|
||||
assert!(state.apply_statistics(0, RuntimeObservation::unknown()));
|
||||
assert_eq!(state.view.as_ref().unwrap().applied, ApplyStatus::Unknown);
|
||||
state.generation = 1;
|
||||
assert!(!state.apply_statistics(0, Statistics::unknown()));
|
||||
assert!(!state.apply_statistics(0, RuntimeObservation::unknown()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user