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
impl IconSet
Sourcepub fn add(&mut self, owner: &str, reg: &IconReg) -> Result<String, IconError>
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.
Sourcepub fn nearest(&self, name: &str, limit: usize) -> Vec<&str>
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).
Sourcepub fn sprite(&self) -> String
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.
Sourcepub fn use_ref(
&self,
name: &str,
sprite_url: &str,
label: Option<&str>,
) -> Option<String>
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.
Sourcepub fn inline(&self, name: &str, label: Option<&str>) -> Option<String>
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§
Auto Trait Implementations§
impl Freeze for IconSet
impl RefUnwindSafe for IconSet
impl Send for IconSet
impl Sync for IconSet
impl Unpin for IconSet
impl UnsafeUnpin for IconSet
impl UnwindSafe for IconSet
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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