pub struct SharedResolvedTheme { /* private fields */ }Expand description
Wait-free shared resolved theme for concurrent read/write.
Wraps a ResolvedTheme in an arc_swap::ArcSwap so that the render
thread can read theme colors without locking while the main thread updates
them on theme switch or mode change.
§Example
use ftui_style::theme::{Theme, ResolvedTheme, SharedResolvedTheme};
let theme = Theme::default();
let resolved = theme.resolve(true); // dark mode
let shared = SharedResolvedTheme::new(resolved);
// Wait-free read from render thread
let current = shared.load();
assert_eq!(current.primary, resolved.primary);
// Update on theme switch
let light = theme.resolve(false);
shared.store(light);Implementations§
Sourcepub fn new(theme: ResolvedTheme) -> Self
pub fn new(theme: ResolvedTheme) -> Self
Create shared theme from an initial resolved theme.
Sourcepub fn load(&self) -> ResolvedTheme
pub fn load(&self) -> ResolvedTheme
Wait-free read of current resolved theme.
Sourcepub fn store(&self, theme: ResolvedTheme)
pub fn store(&self, theme: ResolvedTheme)
Atomically replace the resolved theme (e.g., on theme switch or mode change).
Auto Trait Implementations§
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