pub struct AppState {
pub server_host: String,
pub server_port: String,
pub export_dir: String,
pub devices: Vec<DeviceState>,
pub selected_device_ids: Vec<String>,
pub transient: TransientUiState,
pub events: Vec<String>,
/* private fields */
}Expand description
Full application state.
This is the single source of truth for all UI-visible data.
Fields§
§server_host: String§server_port: String§export_dir: StringDirectory where locally-recorded Parquet exports are written.
devices: Vec<DeviceState>§selected_device_ids: Vec<String>Devices currently selected for the detail tabs. Multiple devices can be selected at once for side-by-side (FDM mesh) collection.
transient: TransientUiState§events: Vec<String>Implementations§
Source§impl AppState
impl AppState
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Construct default state with localhost webserver settings.
Sourcepub fn push_intent(&mut self, intent: UserIntent)
pub fn push_intent(&mut self, intent: UserIntent)
Queue one user intent.
Sourcepub fn push_device_action(
&mut self,
id: impl Into<String>,
action: DeviceAction,
)
pub fn push_device_action( &mut self, id: impl Into<String>, action: DeviceAction, )
Queue a per-device action addressed to id.
Sourcepub fn drain_intents(&mut self) -> Vec<UserIntent>
pub fn drain_intents(&mut self) -> Vec<UserIntent>
Drain queued intents in FIFO order.
Sourcepub fn push_event(&mut self, message: impl Into<String>)
pub fn push_event(&mut self, message: impl Into<String>)
Append one event line to the global event history.
Sourcepub fn selected_indices(&self) -> Vec<usize>
pub fn selected_indices(&self) -> Vec<usize>
Indices of the currently selected devices, in devices order (so the
detail tabs render columns in a stable order regardless of click order).
Sourcepub fn is_selected(&self, id: &str) -> bool
pub fn is_selected(&self, id: &str) -> bool
Whether the device with the given id is currently selected.
Sourcepub fn toggle_selection(&mut self, id: String)
pub fn toggle_selection(&mut self, id: String)
Toggle membership of id in the selection set.
Sourcepub fn device_index_by_id(&self, id: &str) -> Option<usize>
pub fn device_index_by_id(&self, id: &str) -> Option<usize>
Index of the device with the given id.
Sourcepub fn device_mut_by_id(&mut self, id: &str) -> Option<&mut DeviceState>
pub fn device_mut_by_id(&mut self, id: &str) -> Option<&mut DeviceState>
Mutable reference to the device with the given id.
Sourcepub fn base_http_url(&self) -> String
pub fn base_http_url(&self) -> String
Build the HTTP base URL from host/port fields.
Sourcepub fn device_ws_url(&self, id: &str) -> String
pub fn device_ws_url(&self, id: &str) -> String
Build the per-device WebSocket stream URL.
Sourcepub fn reconcile_devices(
&mut self,
entries: Vec<DeviceListEntry>,
) -> ReconcileOutcome
pub fn reconcile_devices( &mut self, entries: Vec<DeviceListEntry>, ) -> ReconcileOutcome
Reconcile a fresh GET /api/devices payload into per-device state.
Adds new devices (default forms), refreshes live status on existing ones, drops devices that vanished, and auto-selects the first device when the current selection is empty or stale.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AppState
impl RefUnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
impl UnwindSafe for AppState
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.