pub struct Image {
pub id: Option<NodeId>,
pub request: ImageRequest,
pub width: Option<f32>,
pub height: Option<f32>,
pub fit: ImageFit,
pub alignment: ImageAlignment,
}Expand description
Displays an image from an asset, file, network URL, memory buffer, or inline SVG.
Image is declarative: it describes the image source and presentation. The
active shell is responsible for loading, decoding, caching, and repainting
when the image becomes available.
Fields§
§id: Option<NodeId>Explicit node identity.
request: ImageRequestTyped image request consumed by the shell image pipeline.
width: Option<f32>Fixed width in layout points.
height: Option<f32>Fixed height in layout points.
fit: ImageFitHow the image is scaled to fit its layout box.
alignment: ImageAlignmentHow fitted image content is positioned inside its layout box.
Implementations§
Source§impl Image
impl Image
pub fn asset(path: impl Into<String>) -> Self
pub fn file(path: impl Into<String>) -> Self
pub fn network(url: impl Into<String>) -> Self
pub fn memory(bytes: impl Into<Vec<u8>>) -> Self
pub fn svg_text(content: impl Into<String>) -> Self
pub fn from_source(source: ImageSource) -> Self
pub fn id(self, id: NodeId) -> Self
pub fn width(self, width: f32) -> Self
pub fn height(self, height: f32) -> Self
pub fn size(self, width: f32, height: f32) -> Self
pub fn fit(self, fit: ImageFit) -> Self
pub fn alignment(self, alignment: ImageAlignment) -> Self
pub fn semantic_label(self, label: impl Into<String>) -> Self
pub fn cache_size(self, width: u32, height: u32) -> Self
pub fn loading(self, loading: ImageLoadingBehavior) -> Self
pub fn error(self, error: ImageErrorBehavior) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn cache_policy(self, cache_policy: ImageCachePolicy) -> Self
pub fn into_node(self) -> Node
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Image
impl<'de> Deserialize<'de> for Image
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
Source§impl Lower for Image
impl Lower for Image
Source§fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
Lower this widget into the IR, returning the root node id.
Auto Trait Implementations§
impl Freeze for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.