Struct icon_loader::Icon

source ·
pub struct Icon { /* private fields */ }
Expand description

Struct containing information about a themed icon.

Implementations§

source§

impl Icon

source

pub fn icon_name(&self) -> &str

Returns the associated icon’s name.

source

pub fn theme_name(&self) -> &str

Returns the associated icon’s theme name.

source

pub fn files(&self) -> &[IconFile]

Returns the icon files found for the associated icon.

source

pub fn file_for_size(&self, size: u16) -> &IconFile

Returns the file of the associated icon that fits the given size best and has a scale of 1. If there is no exact fit available, the next bigger one is chosen. If there is no bigger one, the next smaller one is returned. If that cannot be found, the scale restriction is ignored.

Arguments
  • size - The ideal size of the returned icon file.
Example
use std::ops::Deref;
use icon_loader::IconLoader;

let loader = IconLoader::new();
if let Some(icon) = loader.load_icon("minimum") {
    let icon_file = icon.file_for_size(32);
};
source

pub fn file_for_size_scaled(&self, size: u16, scale: u16) -> &IconFile

Returns the file of the associated icon that fits the given size and scale best. If there is no exact fit available, the next bigger size is chosen. If there is no bigger fit with the given scale, the next smaller one is returned. If no file with the preferred scale can be found, one with the size size * scale and scale 1 is looked for. If that cannot be found, the scale restriction is ignored.

Arguments
  • size - The ideal size of the returned icon file.
  • scale - The preferred scale of the returned icon file.
Example
use std::ops::Deref;
use icon_loader::IconLoader;

let loader = IconLoader::new();
if let Some(icon) = loader.load_icon("minimum") {
    let icon_file = icon.file_for_size_scaled(32, 2);
};
source

pub fn file_for_size_filtered( &self, size: u16, filter: impl Fn(&IconFile) -> bool ) -> Option<&IconFile>

Returns the file of the associated icon that fits the given size best and matches the provided filter. If there is no exact fit available, the next bigger one is chosen. If there is no bigger one, the next smaller one is returned. Use this, if you want only files of type PNG or anything like that.

Arguments
  • size - The ideal size of the returned icon file.
  • filter - A function that takes a reference to an IconFile and returns true, if it passes the test and false otherwise.
Example
use std::ops::Deref;
use icon_loader::{IconLoader, IconFileType};

let loader = IconLoader::new();
if let Some(icon) = loader.load_icon("minimum") {
    let icon_file = icon.file_for_size_filtered(32, |file| file.icon_type() == IconFileType::PNG);
};

Trait Implementations§

source§

impl Clone for Icon

source§

fn clone(&self) -> Icon

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Icon

source§

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

Formats the value using the given formatter. Read more
source§

impl Hash for Icon

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Icon> for Icon

source§

fn eq(&self, other: &Icon) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Icon

source§

impl StructuralEq for Icon

source§

impl StructuralPartialEq for Icon

Auto Trait Implementations§

§

impl RefUnwindSafe for Icon

§

impl Send for Icon

§

impl Sync for Icon

§

impl Unpin for Icon

§

impl UnwindSafe for Icon

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.