pub struct LvCell<T>(/* private fields */);Expand description
Cell<T> for state mutated only from a single logical thread at a time.
Marked Sync — the caller is responsible for upholding the
single-access invariant (e.g. via a lock like LVGL’s, or by structural
guarantees in an embedded setup/run/teardown flow).
Pairs naturally with crate::InitCell for app-wide state.
Implementations§
Source§impl<T> LvCell<T>
impl<T> LvCell<T>
Sourcepub const fn new(v: T) -> Self
pub const fn new(v: T) -> Self
Construct a new cell holding v. Usable in static/const contexts.
Sourcepub fn get_ref(&self) -> &T
pub fn get_ref(&self) -> &T
Borrow the contents without copying.
§Safety contract
Same single-threaded-access invariant as the rest of LvCell:
the caller must ensure no concurrent mutation while the
returned reference is live. Useful for hot loops over large
Copy payloads (e.g. multi-byte buffers in benchmark inner
loops) where get()’s implicit copy would dominate.
Sourcepub fn as_ptr(&self) -> *mut T
pub fn as_ptr(&self) -> *mut T
Raw pointer to the contents — same caveat as
core::cell::Cell::as_ptr. Combined with the LvCell
single-threaded-access invariant this lets a hot path build
a temporary &mut T for in-place updates without going
through get()’s Copy + set()’s Copy round-trip.