pub enum ImageSource {
Placeholder(Size<f32>),
Asset(ImageAsset),
Bytes(Bytes),
}Expand description
An image source describes the source of an image that can be passed to e.g. the Image component. An image source can either be a placeholder, an Asset or a Bytes (3rd party crate) object.
Variants§
Placeholder(Size<f32>)
If you’re loading a remote image, you might want to show a placeholder instead. The placeholder is entirely transparent (unless you give the containing component an opaque background color) but does have a size. This size is subsequently used in calculating the layout.
The benefit of this is that when the image is eventually completely loaded and the component re-renders to show that image, the rest of the layout will not change because it already anticipated the correct size of the image.
Asset(ImageAsset)
This image source is backed by a local asset that is included in a Polyhorn package.
Bytes(Bytes)
This image source is backed by an PNG-encoded buffer.
Implementations§
Source§impl ImageSource
impl ImageSource
Sourcepub fn placeholder(width: f32, height: f32) -> ImageSource
pub fn placeholder(width: f32, height: f32) -> ImageSource
Returns a placeholder image source with the given width and height.
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for ImageSource
impl Default for ImageSource
Source§impl From<&'static [u8]> for ImageSource
impl From<&'static [u8]> for ImageSource
Source§impl From<Bytes> for ImageSource
impl From<Bytes> for ImageSource
Source§impl From<ImageAsset> for ImageSource
impl From<ImageAsset> for ImageSource
Source§fn from(asset: ImageAsset) -> Self
fn from(asset: ImageAsset) -> Self
Source§impl PartialEq for ImageSource
impl PartialEq for ImageSource
impl StructuralPartialEq for ImageSource
Auto Trait Implementations§
impl !Freeze for ImageSource
impl RefUnwindSafe for ImageSource
impl Send for ImageSource
impl Sync for ImageSource
impl Unpin for ImageSource
impl UnwindSafe for ImageSource
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
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,
Source§impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
impl<T, U> ConvertInto<U> for Twhere
U: ConvertFrom<T>,
Source§fn convert_into(self) -> U
fn convert_into(self) -> U
Source§fn convert_unclamped_into(self) -> U
fn convert_unclamped_into(self) -> U
Source§fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
fn try_convert_into(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains the unclamped color. Read more