pub struct WindowStateDocument {
pub version: u32,
pub windows: Vec<WindowSnapshot>,
}Expand description
Versioned set of persisted top-level window snapshots.
An empty vector is valid. Duplicate or empty window identifiers are stored;
Self::snapshot_for returns the first exact match. Deserialization
preserves any version until AppStorage::read_window_state validates it.
§Examples
use ailloli_ui_app_storage::{WindowSnapshot, WindowStateDocument};
let document = WindowStateDocument::new(vec![WindowSnapshot::new("main")]);
assert!(document.snapshot_for("main").is_some());Fields§
§version: u32Persisted schema version; the current supported value is WINDOW_STATE_VERSION.
windows: Vec<WindowSnapshot>Snapshots in caller-provided order; an empty list represents no saved windows.
Implementations§
Source§impl WindowStateDocument
impl WindowStateDocument
Sourcepub fn new(windows: Vec<WindowSnapshot>) -> Self
pub fn new(windows: Vec<WindowSnapshot>) -> Self
Creates a current-version document from snapshots stored verbatim.
§Examples
use ailloli_ui_app_storage::{WindowSnapshot, WindowStateDocument};
let document = WindowStateDocument::new(vec![WindowSnapshot::new("main")]);
assert_eq!(document.windows.len(), 1);Sourcepub fn empty() -> Self
pub fn empty() -> Self
Creates a current-version document with no snapshots.
§Examples
use ailloli_ui_app_storage::WindowStateDocument;
assert!(WindowStateDocument::empty().windows.is_empty());Sourcepub fn snapshot_for(&self, window_id: &str) -> Option<&WindowSnapshot>
pub fn snapshot_for(&self, window_id: &str) -> Option<&WindowSnapshot>
Returns the first snapshot whose identifier exactly equals window_id.
Returns None for no match, including when the document is empty. The
lookup is linear in the number of windows.
§Examples
use ailloli_ui_app_storage::{WindowSnapshot, WindowStateDocument};
let document = WindowStateDocument::new(vec![WindowSnapshot::new("main")]);
assert_eq!(document.snapshot_for("missing"), None);Trait Implementations§
Source§impl Clone for WindowStateDocument
impl Clone for WindowStateDocument
Source§fn clone(&self) -> WindowStateDocument
fn clone(&self) -> WindowStateDocument
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WindowStateDocument
impl Debug for WindowStateDocument
Source§impl Default for WindowStateDocument
impl Default for WindowStateDocument
Source§impl<'de> Deserialize<'de> for WindowStateDocument
impl<'de> Deserialize<'de> for WindowStateDocument
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for WindowStateDocument
impl PartialEq for WindowStateDocument
Source§impl Serialize for WindowStateDocument
impl Serialize for WindowStateDocument
impl StructuralPartialEq for WindowStateDocument
Auto Trait Implementations§
impl Freeze for WindowStateDocument
impl RefUnwindSafe for WindowStateDocument
impl Send for WindowStateDocument
impl Sync for WindowStateDocument
impl Unpin for WindowStateDocument
impl UnwindSafe for WindowStateDocument
Blanket Implementations§
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
Mutably borrows from an owned value. Read more