pub struct State<T: Copy> { /* private fields */ }Expand description
Reactive integer state backed by LVGL’s observer subsystem
(lv_subject_t). Bind widget properties to a State and they
update automatically when you call State::set.
§Stability requirement
lv_subject_t keeps a linked list of observer references, so the
State address must be stable from the moment any observer attaches.
The intended usage is inside a static slot — either a raw static
declared by the user, or via the ove::shared! macro. Dropping a
State while observers are still attached will corrupt the observer
list. PhantomPinned prevents move after construction.
use ove::lvgl::{State, Label};
ove::shared!(COUNTER: State<i32>);
// init once:
COUNTER.init(State::new(0));
// bind:
Label::create(screen).bind_text(COUNTER.get_ref(), b"Count: %d\0");
// update from anywhere:
COUNTER.get_ref().set(42); // label updates automaticallyImplementations§
Source§impl<T: Copy + Into<i32> + TryFrom<i32>> State<T>
impl<T: Copy + Into<i32> + TryFrom<i32>> State<T>
Sourcepub fn set(&self, value: T)
pub fn set(&self, value: T)
Set a new value. All bound widgets update immediately.
Takes &self rather than &mut self because LVGL serializes
observer notification under the global LVGL lock — the lock is
the real mutex, not Rust’s borrow checker.
Sourcepub fn get(&self) -> T
pub fn get(&self) -> T
Read the current value. Falls back to a zeroed T if the stored
i32 cannot be converted back to T (unreachable for well-typed
integer states).
Sourcepub fn subject_ptr(&self) -> *mut lv_subject_t
pub fn subject_ptr(&self) -> *mut lv_subject_t
Returns the raw *mut lv_subject_t for widget binding.