pub struct ImageProps {
pub source: ImageSource,
pub alt: String,
pub aspect_ratio: Option<String>,
pub placeholder_label: Option<String>,
}Expand description
Props for an Component::Image component.
source is a flattened ImageSource — the wire format carries
either "src" (URL variant) or "svg" (inline-SVG variant) directly
at the top level, with no wrapping "source" key. alt is required
on both variants (compile-enforced accessibility for the SVG branch).
Fields§
§source: ImageSourceImage source — URL or server-constructed inline SVG.
Flattened into the parent JSON object: the src or svg field
appears directly on ImageProps in the wire format.
alt: StringRequired alt text for accessibility. HTML-escaped on both source variants.
aspect_ratio: Option<String>Optional CSS aspect ratio (e.g. "16/9"). Applied to both variants.
placeholder_label: Option<String>Optional label shown in a skeleton placeholder that sits behind the
image in the URL variant. When the <img> fails to load (or is still
being generated), the element is hidden via onerror and the
placeholder remains visible. Not rendered for the InlineSvg variant.
Implementations§
Source§impl ImageProps
impl ImageProps
Sourcepub fn url(src: impl Into<String>, alt: impl Into<String>) -> Self
pub fn url(src: impl Into<String>, alt: impl Into<String>) -> Self
Construct an ImageProps backed by an external URL.
Both src and alt accept impl Into<String> for ergonomic call
sites. aspect_ratio and placeholder_label default to None — set
them explicitly on the returned struct if needed.
Sourcepub fn inline_svg(svg: impl Into<String>, alt: impl Into<String>) -> Self
pub fn inline_svg(svg: impl Into<String>, alt: impl Into<String>) -> Self
Construct an ImageProps backed by a server-constructed inline SVG.
§Safety
svg is emitted verbatim without HTML escaping. Intended for
server-constructed SVG (charts, sparklines, icons). Not suitable
for user-supplied strings. Callers that incorporate user data into
svg are responsible for sanitization before calling this
constructor. See ImageSource::InlineSvg for the full contract.
Trait Implementations§
Source§impl Clone for ImageProps
impl Clone for ImageProps
Source§fn clone(&self) -> ImageProps
fn clone(&self) -> ImageProps
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 ImageProps
impl Debug for ImageProps
Source§impl<'de> Deserialize<'de> for ImageProps
impl<'de> Deserialize<'de> for ImageProps
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>,
Source§impl JsonSchema for ImageProps
impl JsonSchema for ImageProps
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ImageProps
impl PartialEq for ImageProps
Source§fn eq(&self, other: &ImageProps) -> bool
fn eq(&self, other: &ImageProps) -> bool
self and other values to be equal, and is used by ==.