pub struct ImageOptions {
pub src: String,
pub width: Option<u32>,
pub height: Option<u32>,
pub alt: String,
pub quality: u8,
pub fill: bool,
pub sizes: Option<String>,
pub priority: bool,
pub placeholder: Placeholder,
pub loading: Loading,
pub unoptimized: bool,
}Expand description
Every <Image ...> attribute, one field each - see this crate’s own
doc comment for the full meaning of each one. Owned Strings, not
borrowed &strs, deliberately: larust-macros’ own codegen (which
constructs this struct literal directly, one field per attribute, no
builder calls needed there) hands it a :src="expr" dynamic
attribute’s own value exactly as whatever type that expression
produces (String, &str, anything Display) - converted uniformly
via .to_string() either way - rather than needing a lifetime
parameter here just to borrow a value that’s just as often a literal
as it is some other owned value computed on the spot.
ImageOptions::new/ImageOptions::fill plus the builder-style
setters below are for a hand-written Rust call site instead, and
accept impl Into<String> so a plain &str literal still needs no
extra ceremony there either.
Fields§
§src: String§width: Option<u32>§height: Option<u32>§alt: String§quality: u8§fill: bool§sizes: Option<String>§priority: bool§placeholder: Placeholder§loading: Loading§unoptimized: boolImplementations§
Source§impl ImageOptions
impl ImageOptions
Sourcepub fn new(src: impl Into<String>, width: u32, height: u32) -> ImageOptions
pub fn new(src: impl Into<String>, width: u32, height: u32) -> ImageOptions
A fixed-box image - the common case.
Sourcepub fn fill(src: impl Into<String>) -> ImageOptions
pub fn fill(src: impl Into<String>) -> ImageOptions
A fill-mode image - expands to its parent’s own box, which must
have position: relative/absolute/fixed in your own CSS.
pub fn alt(self, alt: impl Into<String>) -> ImageOptions
pub fn quality(self, quality: u8) -> ImageOptions
Sourcepub fn sizes(self, sizes: impl Into<String>) -> ImageOptions
pub fn sizes(self, sizes: impl Into<String>) -> ImageOptions
Also triggers build_srcset generation - see this crate’s own
sizes doc bullet above.
Sourcepub fn priority(self) -> ImageOptions
pub fn priority(self) -> ImageOptions
Also forces Loading::Eager - Next.js’s own identical coupling
(loading is ignored, treated as "eager", whenever priority is
set).
pub fn placeholder(self, placeholder: Placeholder) -> ImageOptions
pub fn loading(self, loading: Loading) -> ImageOptions
pub fn unoptimized(self) -> ImageOptions
Trait Implementations§
Source§impl Clone for ImageOptions
impl Clone for ImageOptions
Source§fn clone(&self) -> ImageOptions
fn clone(&self) -> ImageOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ImageOptions
impl RefUnwindSafe for ImageOptions
impl Send for ImageOptions
impl Sync for ImageOptions
impl Unpin for ImageOptions
impl UnsafeUnpin for ImageOptions
impl UnwindSafe for ImageOptions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Event for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more