pub enum Decoding {
Sync,
Async,
Auto,
}Expand description
The decoding attribute values for image decoding.
§Purpose
Provides a hint to the browser about how to decode the image, allowing optimization of the decoding strategy for better user experience.
§Usage Context
- Used with:
<img>elements - Performance: Affects when/how images are decoded relative to page rendering
- Default: Browser-dependent
§Valid Values
Sync: Decode the image synchronously for atomic presentation with other contentAsync: Decode the image asynchronously to avoid delaying other contentAuto: Let the browser decide the optimal decoding mode
§Example
use ironhtml_attributes::{AttributeValue, Decoding};
let decoding = Decoding::Async;
assert_eq!(decoding.to_attr_value(), "async");<img src="hero.jpg" decoding="sync" alt="Decode with page content">
<img src="gallery.jpg" decoding="async" alt="Decode asynchronously">
<img src="photo.jpg" decoding="auto" alt="Browser decides">§WHATWG Specification
Variants§
Sync
Decode the image synchronously along with other page content for atomic presentation. May delay rendering.
Async
Decode the image asynchronously to reduce delay in presenting other content. Image may render after initial page load.
Auto
Allow the browser to choose the decoding strategy. This is the recommended default.
Trait Implementations§
Source§impl AttributeValue for Decoding
impl AttributeValue for Decoding
Source§fn to_attr_value(&self) -> Cow<'static, str>
fn to_attr_value(&self) -> Cow<'static, str>
Convert to the attribute value string.
impl Copy for Decoding
impl Eq for Decoding
impl StructuralPartialEq for Decoding
Auto Trait Implementations§
impl Freeze for Decoding
impl RefUnwindSafe for Decoding
impl Send for Decoding
impl Sync for Decoding
impl Unpin for Decoding
impl UnwindSafe for Decoding
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