Skip to main content

IconSet

Struct IconSet 

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

The icons available to a running application: the framework’s set plus what modules contributed.

Implementations§

Source§

impl IconSet

Source

pub fn new() -> Self

The framework’s own set.

Source

pub fn add(&mut self, owner: &str, reg: &IconReg) -> Result<String, IconError>

Adds a module’s own icon, namespaced to it.

The key becomes {owner}:{name}, so a bare name stays reserved to the framework and two modules cannot collide however they name things.

Source

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

Whether a name resolves.

Source

pub fn body(&self, name: &str) -> Option<&str>

The drawing instructions for a name.

Source

pub fn len(&self) -> usize

How many icons are available.

Source

pub fn is_empty(&self) -> bool

Whether the set is empty, which it never is in practice.

Source

pub fn nearest(&self, name: &str, limit: usize) -> Vec<&str>

Names closest to name, for telling an author what they probably meant.

Substring matches first, then names sharing a leading word, which between them catch the mistakes people actually make: a near-miss (user for users) and a wrong suffix (chart-bars for chart-bar).

Source

pub fn sprite(&self) -> String

Every icon as one SVG sprite, for serving at a single cached URL.

A symbol carries viewBox and nothing else. A presentation attribute here would beat whatever the use site inherits and could not be reached by page CSS, so stroke, fill and caps stay on the outer element where a consumer can restyle them.

Source

pub fn use_ref( &self, name: &str, sprite_url: &str, label: Option<&str>, ) -> Option<String>

A reference into the sprite: two nodes and about seventy bytes, against the few hundred an inlined glyph costs every time it renders.

Decorative by default, for the same reason as IconSet::inline.

Source

pub fn inline(&self, name: &str, label: Option<&str>) -> Option<String>

Inline SVG for a name, for a context that cannot fetch a sprite.

Decorative by default: a screen reader skips it, because an icon beside a label repeats the label. Pass a label only when the icon is the whole meaning, and prefer naming the button around it.

Trait Implementations§

Source§

impl Default for IconSet

Source§

fn default() -> Self

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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
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 = !

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

impl<T> WithSubscriber for T

Source§

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

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

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