pub enum ImageSource {
Url {
src: String,
},
InlineSvg {
svg: String,
},
}Expand description
Source for an ImageProps component — exactly one of src or svg.
Wire-format discrimination is by field presence via #[serde(untagged)]:
{"src": "/logo.png"}deserializes toImageSource::Url.{"svg": "<svg>…</svg>"}deserializes toImageSource::InlineSvg.
The Url variant is backward-compatible with pre-phase-148 JSON:
existing callers sending {"type":"Image","src":"…","alt":"…"} continue
to deserialize unchanged.
Variants§
Url
External image URL. The src attribute is HTML-escaped before emission.
InlineSvg
Server-constructed inline SVG string.
§Safety
The svg value is emitted verbatim, without HTML escaping. This is
the single deliberate html_escape bypass in ferro-json-ui. It is
intended for server-constructed SVG — charts, sparklines, icons —
not for user-supplied strings.
Callers that incorporate user data into SVG output are responsible for
sanitization before constructing this variant. Contrast with
ImageSource::Url: src is always HTML-escaped as an attribute
value, so Url is safe with caller-controlled URL strings.
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 Debug for ImageSource
impl Debug for ImageSource
Source§impl<'de> Deserialize<'de> for ImageSource
impl<'de> Deserialize<'de> for ImageSource
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 ImageSource
impl JsonSchema for ImageSource
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 more