Skip to main content

InMemoryThemeRegistry

Struct InMemoryThemeRegistry 

Source
pub struct InMemoryThemeRegistry { /* private fields */ }
Expand description

In-memory ThemeRegistry. Holds the element table + active palette behind an RwLock, and the resolved read table behind an ArcSwap for lock-free reads.

Implementations§

Source§

impl InMemoryThemeRegistry

Source

pub fn new(palette: Palette) -> InMemoryThemeRegistry

Empty registry with the given palette. Register elements, then resolved() builds the table on first read.

Source

pub fn with_defaults() -> InMemoryThemeRegistry

Registry seeded with the default palette + all builtin core elements, resolved and ready. The T.3 boot path + tests use this.

Source

pub fn set_palette(&self, palette: Palette)

Replace the active palette (a :colorscheme / :set ui.* path lands in T.9). Marks the table dirty.

Source

pub fn rebuild(&self)

Re-resolve every element into a fresh ResolvedTheme and publish it. Called on dirty reads; O(elements), theme-build time only (never on the hot path).

Trait Implementations§

Source§

impl ThemeRegistry for InMemoryThemeRegistry

Source§

fn register( &self, name: ElementName, owner: ElementOwner, default: StyleSpec, doc: &'static str, ) -> ElementId

Register an element with its owner-supplied default. Idempotent by name — re-registering an existing name returns the existing id and leaves its default unchanged.
Source§

fn id(&self, name: &ElementName) -> Option<ElementId>

The interned id for a name, if registered.
Source§

fn unregister_element(&self, name: &ElementName) -> bool

TC.4: withdraw an element by name — the reverse of Self::register, used when a plugin unloads. Returns whether a name was removed (idempotent: a second unload removes nothing). Read more
Source§

fn resolved(&self) -> Arc<ResolvedTheme> ⓘ

The current resolved read table (rebuilt lazily if a registration / palette change left it dirty).
Source§

fn set_override(&self, name: ElementName, spec: StyleSpec)

T.9: set (or replace) the theme-global override for an element (:set ui.*, user TOML, a theme’s override list). Overlays the override’s set fields on the element’s resolved default. Marks the table dirty (re-resolved on next resolved()).
Source§

fn set_theme(&self, palette: Palette, overrides: Vec<(ElementName, StyleSpec)>)

T.9: swap the active theme — replace the palette AND the full override set atomically (:colorscheme). Prior overrides are cleared. Marks the table dirty.
Source§

fn register_theme(&self, theme: NamedTheme)

T.11.1: register (or replace, by name) a named theme in the catalog. Idempotent by name — re-registering a name replaces its palette + overrides. This is the seam init.rs (and, later, a WASM plugin via WIT) uses to contribute a palette; the builtin themes are seeded here at boot. Does NOT change the active theme — only apply_theme does that.
Source§

fn theme_names(&self) -> Vec<String>

T.11.1: the names of every registered theme, in registration order (builtins first, then user/plugin additions). Drives :colorscheme completion + the T.12 picker.
Source§

fn element_names(&self) -> Vec<String>

T.9.d follow-up: the names of every registered theme element, sorted. Drives :describe-element / :describe-face <Tab> completion (the gen:elements host generator). Sorted so popup ordering is stable across runs; a theme-build-time read, never on the hot path.
Source§

fn apply_theme(&self, name: &str) -> bool

T.11.1: swap the active theme to the registered theme name (:colorscheme <name>). Returns false (active theme untouched) if name is not registered — the caller echoes an error, never a panic. On a hit, equivalent to set_theme with the registered theme’s palette + overrides (marks the table dirty).
Source§

fn active_theme(&self) -> (Palette, Vec<(ElementName, StyleSpec)>)

T.12a: snapshot the active palette + the active theme-global override set as a (Palette, Vec<(ElementName, StyleSpec)>) pair. The colorscheme picker captures this on the first live preview so <Esc> can restore the theme active when the picker opened via Self::set_theme. Cheap clone of the inner state under a read lock; no resolution.
Source§

fn describe(&self, name: &ElementName) -> Option<ElementInfo>

T.9.d: element metadata for introspection (:describe-element / :describe-face). Returns the element’s identity + owner + authoring default + doc + concrete resolved style, or None if name is not a registered element. Reads the resolved table (rebuilding it lazily if dirty) so the resolved field reflects the active theme — a theme-build-time read, never on the hot path.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoMaybeUndefined<T> for T

§

fn into_maybe_undefined(self) -> MaybeUndefined<T>

Converts this value into a three-state builder argument.
§

impl<T> IntoOption<T> for T

§

fn into_option(self) -> Option<T>

Converts this value into an optional builder argument.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Pointer = u32

§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more