Struct AppIcon

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

Embedded SVG used as an application or per-window icon.

§Examples

use ailloli_ui_core::AppIcon;

let icon = AppIcon::from_static_svg(b"<svg/>", "assets/icon.svg");
assert_eq!(icon.bytes(), b"<svg/>");
assert_eq!(icon.source_path(), "assets/icon.svg");

Implementations§

Source§

impl AppIcon

Source

pub fn from_static_svg( bytes: &'static [u8], source_path: impl Into<String>, ) -> Self

Creates an icon from compile-time embedded SVG bytes.

source_path is diagnostic and packaging metadata; this function does not read that path or validate the SVG document.

§Examples
use ailloli_ui_core::AppIcon;
let icon = AppIcon::from_static_svg(b"<svg/>", "assets/icon.svg");
assert_eq!(icon.bytes(), b"<svg/>");
Source

pub fn from_svg_bytes( bytes: impl Into<Arc<[u8]>>, source_path: impl Into<String>, ) -> Self

Creates an icon from shared owned SVG bytes.

This form is useful for per-window overrides and tooling that loads the bytes dynamically. source_path remains descriptive: it is never read and the SVG bytes are not validated here.

§Examples
use ailloli_ui_core::AppIcon;
let icon = AppIcon::from_svg_bytes(Vec::from(&b"<svg/>"[..]), "generated.svg");
assert_eq!(icon.source_path(), "generated.svg");
Source

pub fn source(&self) -> &SvgSource

Returns the borrowed SVG source consumed by widgets and rasterizers.

§Examples
use ailloli_ui_core::{AppIcon, SvgSource};
let icon = AppIcon::from_static_svg(b"<svg/>", "icon.svg");
assert!(matches!(icon.source(), SvgSource::Static(_)));
Source

pub fn bytes(&self) -> &[u8] ⓘ

Returns the raw, unvalidated SVG bytes.

§Examples
use ailloli_ui_core::AppIcon;
assert_eq!(AppIcon::from_static_svg(b"abc", "icon.svg").bytes(), b"abc");
Source

pub fn source_path(&self) -> &str

Returns the logical source path retained for diagnostics and packaging.

§Examples
use ailloli_ui_core::AppIcon;
assert_eq!(AppIcon::from_static_svg(b"", "assets/icon.svg").source_path(), "assets/icon.svg");
Source

pub fn sha256(&self) -> String

Computes the lowercase hexadecimal SHA-256 digest of the source bytes.

The returned string always contains 64 ASCII hexadecimal characters and does not incorporate Self::source_path.

§Examples
use ailloli_ui_core::AppIcon;
assert_eq!(AppIcon::from_static_svg(b"", "icon.svg").sha256().len(), 64);

Trait Implementations§

Source§

impl Clone for AppIcon

Source§

fn clone(&self) -> AppIcon

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 AppIcon

Source§

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

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> Same for T

Source§

type Output = T

Should always be Self
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 = 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 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.