virtualizer/
state.rs

1use crate::Rect;
2
3/// A lightweight, serializable snapshot of the current viewport geometry.
4///
5/// With `feature = "serde"`, this type implements `Serialize`/`Deserialize`.
6#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct ViewportState {
9    pub rect: Rect,
10}
11
12/// A lightweight, serializable snapshot of the current scroll state.
13///
14/// With `feature = "serde"`, this type implements `Serialize`/`Deserialize`.
15#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17pub struct ScrollState {
18    pub offset: u64,
19    pub is_scrolling: bool,
20}
21
22/// A combined snapshot of viewport + scroll state.
23///
24/// This is useful for restoring UI state across frames or sessions without
25/// coupling the virtualizer to any specific UI framework.
26#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
27#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
28pub struct FrameState {
29    pub viewport: ViewportState,
30    pub scroll: ScrollState,
31}