Skip to main content

ThemeCatalog

Struct ThemeCatalog 

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

Theme index with embedded built-ins and optional custom documents. In-memory operations never read environment variables or access the filesystem.

Implementations§

Source§

impl ThemeCatalog

Source

pub fn builtin() -> Result<ThemeCatalog, ThemeError>

Create a catalog from embedded themes, without accessing disk or environment.

Source

pub fn load() -> Result<ThemeCatalog, ThemeError>

Load embedded themes, user themes, and the persisted native selection.

Source

pub fn get(&self, id: &str) -> Option<&ThemeEntry>

Source

pub fn iter(&self) -> impl Iterator<Item = (&str, &ThemeEntry)>

Source

pub fn active_id(&self) -> &str

Source

pub fn active_appearance(&self) -> Appearance

Source

pub fn revision(&self) -> u64

Stable within a process and sensitive to theme documents, selection, appearance, additions, and removals. Web adapters use this revision to publish change events without exposing filesystem paths.

Source

pub fn export_family(&self, family: &str) -> Option<ThemePackDocument>

Export every built-in and custom theme in a named family as one pack.

Source

pub fn pack_conflicts(&self, pack: &ThemePackDocument) -> PackConflicts

Report custom and built-in ID collisions without changing the catalog.

Source

pub fn import_pack( &mut self, pack: ThemePackDocument, policy: PackConflictPolicy, ) -> Result<PackImportReport, ThemeError>

Import a validated pack after resolving all ID collisions up front. Reject policy guarantees no writes occur if any ID conflicts.

Source

pub fn import_pack_in_memory( &mut self, pack: ThemePackDocument, policy: PackConflictPolicy, ) -> Result<PackImportReport, ThemeError>

Import into memory. Validation and collision checks precede all mutations.

Source

pub fn save(&mut self, document: ThemeDocument) -> Result<(), ThemeError>

Save a portable custom theme to the shared user theme folder.

Source

pub fn insert_custom( &mut self, document: ThemeDocument, ) -> Result<(), ThemeError>

Insert or replace a custom theme without persisting it. Built-ins are protected.

Source

pub fn select(&mut self, id: &str) -> Result<(), ThemeError>

Source

pub fn set_active(&mut self, id: &str) -> Result<(), ThemeError>

Select a theme in memory without persisting it.

Source

pub fn set_appearance( &mut self, appearance: Appearance, ) -> Result<(), ThemeError>

Source

pub fn set_active_appearance(&mut self, appearance: Appearance)

Change appearance in memory without persisting it.

Source

pub fn remove_custom(&mut self, id: &str) -> Result<bool, ThemeError>

Source

pub fn remove_custom_entry(&mut self, id: &str) -> Result<bool, ThemeError>

Remove a custom entry in memory, falling back to the embedded default if active.

Trait Implementations§

Source§

impl Clone for ThemeCatalog

Source§

fn clone(&self) -> ThemeCatalog

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ThemeCatalog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.