pub struct Image<'a> {
pub alt: &'a str,
pub caption: Option<&'a str>,
pub fit: Fit,
}Expand description
A picture, and what it says to someone who is not looking at it.
§No source
Act’s split, for Act’s reason. A source is an address, and this
crate has no notion of an address: it says what a thing is and the caller
keeps what it points at. The three findings dropped from 0.11.0 were all
this same shape.
It matters more here than it does for a control, because a picture is the
one member where the address is most of what a webview needs and none of
what the description knows. quasi_router::Node::Image carries the URL, the
way it carries an Action for a control.
§Why alt is not optional
Every other host has to draw something, and for two of the three the alt text is not a fallback but the whole rendering: a terminal without a graphics protocol has the words and nothing else. Making it optional would make “this picture is invisible on a terminal” the default, and the description would be carrying a webview assumption in its shape.
An image that genuinely says nothing — a rule, a spacer, a decoration
repeating what the text beside it already said — is an empty alt, which is
the same thing HTML means by it and is a claim rather than an oversight.
Fields§
§alt: &'a strWhat the picture says, for anything not showing it.
Empty means the picture is decorative and adds nothing to the text
around it. See the type’s own docs on why this is not an Option.
caption: Option<&'a str>A visible line under the picture, where the app wants one.
Distinct from alt and the difference is who it is for: a
caption is content everybody reads, alt text is what stands in for the
picture. A screenshot captioned “The library view” still needs alt text
describing what is in the shot.
fit: FitHow it sits in the box it is given.
Implementations§
Source§impl<'a> Image<'a>
impl<'a> Image<'a>
Sourcepub const fn speaks(self) -> bool
pub const fn speaks(self) -> bool
Whether the picture adds anything for someone not looking at it.
A renderer with no way to show a picture uses this to decide between drawing the alt text and drawing nothing at all. Both are correct and the difference is this flag: standing in for a decorative rule with the word “decoration” is worse than leaving the space empty.