Skip to main content

Theme

Struct Theme 

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

An index of the cursor themes on disk.

Cheap to construct – a directory walk and a small metadata parse, no pixels. Resolutions are memoized for the index’s lifetime, hits and misses alike, so a caller cycling through a fixed set of shapes pays the walk once per name.

The index is a snapshot: cursors appearing or disappearing on disk afterwards are not noticed. Build a new one, which is cheap.

Not Sync. The memo cache is a RefCell, matching the reference, which documents Theme as unsynchronized. Sharing one across threads is a compile error rather than a race.

Implementations§

Source§

impl Theme

Source

pub fn discover() -> Result<Self, CursorError>

Index the themes on the standard search path.

§Errors

CursorError::NoThemes when no theme directory is readable at all. That is deliberately distinct from a resolve failing on a healthy index: one means nothing is installed, the other means this cursor is not in what is installed, and a caller wants to say different things about them.

Source

pub fn discover_with_paths( search_paths: &[PathBuf], ) -> Result<Self, CursorError>

Index the themes under an explicit set of roots.

The seam the tests use, so they can point at a fixture tree rather than whatever the machine happens to have installed.

§Errors

As Theme::discover.

Source

pub fn search_paths(&self) -> &[PathBuf]

The roots this index was built from.

Source

pub fn theme_names(&self) -> Vec<&str>

The themes indexed, in discovery order.

Source

pub fn resolve( &self, cursor_name: &str, preferred_theme: &str, ) -> Result<ThemeResolution, CursorError>

Resolve a cursor name to a file.

preferred_theme may be empty, in which case $XCURSOR_THEME is used, then default. The Inherits= chain is followed breadth-first and every alias of the name is tried in each theme.

§Errors

Trait Implementations§

Source§

impl Debug for Theme

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Theme

§

impl !RefUnwindSafe for Theme

§

impl !Sync for Theme

§

impl Send for Theme

§

impl Unpin for Theme

§

impl UnsafeUnpin for Theme

§

impl UnwindSafe for Theme

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> 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, 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.