Skip to main content

Dimensions

Struct Dimensions 

Source
pub struct Dimensions { /* private fields */ }
Expand description

A (width, height) pair in pixels.

Lives alongside the rest of the frame primitives because the same pair shows up everywhere a video stream is described — the coded dimensions of a VideoFrame, the coded_* parameters a backend adapter takes when opening a decoder, the per-plane layout helpers in a WebCodecs adapter, etc. Passing it as a single struct rather than two separate u32 arguments removes a long-running footgun (silent argument swap) and gives a natural place to hang helpers like Self::is_zero or Display.

u32 width / height matches WebCodecs’ coded_width / coded_height typing in web_sys and FFmpeg’s AVCodecContext::width / height. 65535×65535 (the smaller u16 packing some adjacent crates use) covers every realistic resolution; the u32 choice here keeps the public API plug- compatible with both adapter typings.

Implementations§

Source§

impl Dimensions

Source

pub const fn new(width: u32, height: u32) -> Dimensions

Constructs a Dimensions with the specified width and height in pixels.

Source

pub const fn width(&self) -> u32

Returns the width in pixels.

Source

pub const fn height(&self) -> u32

Returns the height in pixels.

Source

pub const fn with_width(self, width: u32) -> Dimensions

Sets the width (consuming builder).

Source

pub const fn set_width(&mut self, width: u32) -> &mut Dimensions

Sets the width in place.

Source

pub const fn with_height(self, height: u32) -> Dimensions

Sets the height (consuming builder).

Source

pub const fn set_height(&mut self, height: u32) -> &mut Dimensions

Sets the height in place.

Source

pub const fn is_zero(&self) -> bool

Returns true when both width and height are zero — typically the default-constructed / unset state.

Trait Implementations§

Source§

impl Clone for Dimensions

Source§

fn clone(&self) -> Dimensions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Dimensions

Source§

impl Debug for Dimensions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Dimensions

Source§

fn default() -> Dimensions

Returns the “default value” for a type. Read more
Source§

impl Display for Dimensions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Dimensions

Source§

impl Hash for Dimensions

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Dimensions

Source§

fn eq(&self, other: &Dimensions) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Dimensions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.