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
impl AppIcon
Sourcepub fn from_static_svg(
bytes: &'static [u8],
source_path: impl Into<String>,
) -> Self
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/>");Sourcepub fn from_svg_bytes(
bytes: impl Into<Arc<[u8]>>,
source_path: impl Into<String>,
) -> Self
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");Sourcepub fn source(&self) -> &SvgSource
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(_)));Sourcepub fn bytes(&self) -> &[u8] ⓘ
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");Sourcepub fn source_path(&self) -> &str
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");Sourcepub fn sha256(&self) -> String
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);