pub enum ImageSource {
Named(String),
Bytes(Arc<Vec<u8>>),
Decoded(BitmapId),
}Expand description
Where a raster image’s pixels come from (docs/images.md).
One currency for both halves of the same question: Named is the staged asset every
image(res::images::…) has always drawn, Bytes is an encoded PNG/JPEG the app already
holds (a download, a file the user picked, a clipboard paste), and Decoded names an image
the toolkit decoded once so several nodes (and the canvas) share it.
Variants§
Named(String)
A staged asset name, resolved through the backend’s own pipeline (§18.2).
Bytes(Arc<Vec<u8>>)
Encoded bytes (PNG/JPEG/…) the app owns, decoded by the platform’s own decoder. Shared rather than copied: handing over a new buffer is a refcount bump.
Decoded(BitmapId)
An image already decoded through Toolkit::decode_image.
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImageSource
Logs the buffer’s length, never its contents: a Debug that dumped a megabyte of pixels
into a trace line would make the trace useless and slow.
impl Debug for ImageSource
Logs the buffer’s length, never its contents: a Debug that dumped a megabyte of pixels
into a trace line would make the trace useless and slow.
Source§impl Default for ImageSource
impl Default for ImageSource
Source§fn default() -> ImageSource
fn default() -> ImageSource
Source§impl From<BitmapId> for ImageSource
impl From<BitmapId> for ImageSource
Source§fn from(id: BitmapId) -> ImageSource
fn from(id: BitmapId) -> ImageSource
Source§impl From<ImageName> for ImageSource
A staged asset name is a source, so image(res::images::cover) keeps compiling unchanged.
impl From<ImageName> for ImageSource
A staged asset name is a source, so image(res::images::cover) keeps compiling unchanged.
There is no From<&str> here, for the same reason resource::ImageName has none:
image("typo") must stay a compile error rather than a blank view at runtime (resource.rs).
A path or URL string is not a source either: read the bytes and hand those over.
Source§fn from(name: ImageName) -> ImageSource
fn from(name: ImageName) -> ImageSource
Source§impl From<String> for ImageSource
An owned string is a name, not bytes: the same conversion resource::ImageName offers for
a name computed at runtime, and the reason image(some_string) keeps compiling. A &str
still converts nowhere, so image("typo") stays a compile error (resource.rs).
impl From<String> for ImageSource
An owned string is a name, not bytes: the same conversion resource::ImageName offers for
a name computed at runtime, and the reason image(some_string) keeps compiling. A &str
still converts nowhere, so image("typo") stays a compile error (resource.rs).
Source§fn from(name: String) -> ImageSource
fn from(name: String) -> ImageSource
Source§impl From<VectorName> for ImageSource
impl From<VectorName> for ImageSource
Source§fn from(name: VectorName) -> ImageSource
fn from(name: VectorName) -> ImageSource
Source§impl IntoImageSource<ImageValueMark> for ImageSource
impl IntoImageSource<ImageValueMark> for ImageSource
fn into_image_source(self) -> Reactive<ImageSource>
Source§impl PartialEq for ImageSource
Bytes compare by identity, not content.
impl PartialEq for ImageSource
Bytes compare by identity, not content.
This is the equality a binding gates on (§4.2), so it runs on every evaluation, and
comparing two multi-megabyte buffers byte by byte would cost far more than the redundant
decode it saves. Handing over a distinct buffer holding the same pixels therefore re-decodes,
which is the same trade Arc::ptr_eq makes wherever else Day carries shared buffers.
Auto Trait Implementations§
impl Freeze for ImageSource
impl RefUnwindSafe for ImageSource
impl Send for ImageSource
impl Sync for ImageSource
impl Unpin for ImageSource
impl UnsafeUnpin for ImageSource
impl UnwindSafe for ImageSource
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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