#[non_exhaustive]pub enum IconData {
Svg(Cow<'static, [u8]>),
Rgba(RgbaData),
}Expand description
Icon data returned by loading functions.
Represents the actual pixel or vector data for an icon. This type is produced by platform icon loaders and bundled icon accessors.
§Examples
use native_theme::icons::IconData;
use std::borrow::Cow;
let svg = IconData::Svg(Cow::Borrowed(b"<svg></svg>"));
assert_eq!(svg.bytes(), b"<svg></svg>");
let rgba = IconData::rgba(16, 16, vec![0; 16 * 16 * 4]).unwrap();
assert_eq!(rgba.bytes().len(), 16 * 16 * 4);
// A buffer that is not `width × height × 4` bytes is refused.
assert_eq!(IconData::rgba(16, 16, vec![]), None);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Svg(Cow<'static, [u8]>)
SVG content as raw bytes (from freedesktop themes, bundled icon sets).
Bundled icons use Cow::Borrowed for zero-copy access to compile-time
embedded data. Runtime-loaded icons (freedesktop, custom providers)
use Cow::Owned.
Rgba(RgbaData)
Rasterized RGBA pixels (from macOS/Windows system APIs).
Built with IconData::rgba, which checks the buffer’s length.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for IconData
impl<'de> Deserialize<'de> for IconData
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for IconData
impl StructuralPartialEq for IconData
Auto Trait Implementations§
impl Forget for IconData
impl Freeze for IconData
impl Move for IconData
impl RefUnwindSafe for IconData
impl Send for IconData
impl Sync for IconData
impl Unpin for IconData
impl UnsafeUnpin for IconData
impl UnwindSafe for IconData
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
Mutably borrows from an owned value. Read more