pub enum Preload {
None,
Metadata,
Auto,
}Expand description
The preload attribute values for media elements.
§Purpose
Provides a hint to the browser about what media data to preload, balancing user experience with bandwidth and resource consumption.
§Usage Context
- Used with:
<audio>,<video>elements - Performance: Controls bandwidth usage and buffering behavior
- Default: Browser-dependent (typically
metadata)
§Valid Values
None: Don’t preload any dataMetadata: Preload only metadata (duration, dimensions, first frame)Auto: Browser decides how much to preload (may load entire file)
§Example
use ironhtml_attributes::{AttributeValue, Preload};
let preload = Preload::Metadata;
assert_eq!(preload.to_attr_value(), "metadata");<video src="movie.mp4" preload="none" controls></video>
<video src="tutorial.mp4" preload="metadata" controls></video>
<audio src="music.mp3" preload="auto" controls></audio>§WHATWG Specification
Variants§
None
Don’t preload any data. Minimizes bandwidth usage. User must explicitly start playback.
Metadata
Preload only metadata (duration, dimensions, track list, first frame). Good balance between UX and bandwidth.
Auto
Browser decides whether to preload data. May download the entire resource. Optimizes for user experience.
Trait Implementations§
Source§impl AttributeValue for Preload
impl AttributeValue for Preload
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 Preload
impl Eq for Preload
impl StructuralPartialEq for Preload
Auto Trait Implementations§
impl Freeze for Preload
impl RefUnwindSafe for Preload
impl Send for Preload
impl Sync for Preload
impl Unpin for Preload
impl UnwindSafe for Preload
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