Skip to main content

ChannelLayoutDescription

Struct ChannelLayoutDescription 

Source
pub struct ChannelLayoutDescription { /* private fields */ }
Available on crate features alloc or std only.
Expand description

Audio channel layout, described in full — order + channel count + identification.

The bundle FFmpeg’s AVChannelLayout carries through to consumers, rendered as plain Rust data:

With the serde feature the wire form is a map of those six names, each field in its own shape: order as its u32 code, known_kind as its canonical slug, native_mask as a nullable integer, custom_channels as an array of ChannelSpec maps.

No invariant across the fields. An incoherent combination — a Custom order with an empty channel list, a Native order with no mask — is exactly as constructible through the public setters as a coherent one, so the derive rejects nothing the builders would have accepted, and the fuzz generators deliberately reach those combinations. A consumer that needs coherence checks it.

Implementations§

Source§

impl ChannelLayoutDescription

Source

pub const fn new(channels: u32) -> Self

Constructs a minimal description with the given channel count. Every other field starts at its own absent value (Unspecified order, no name, no mask, no channel list, no rendering); fill them in with the with_* builders.

Source

pub const fn order(&self) -> ChannelOrder

Channel ordering (Native / Custom / Ambisonic / Unspecified).

Source

pub const fn channels(&self) -> u32

Total channel count.

Source

pub const fn known_kind(&self) -> &ChannelLayout

The layout’s name, or ChannelLayout::default — the Other("") absent sentinel — when no well-known shape matches.

Borrowed rather than copied: ChannelLayout carries a SmolStr in its escape arm and so is not Copy.

Source

pub const fn native_mask(&self) -> Option<u64>

Native-order bitmask of AV_CH_* channel positions, when applicable. None for Custom / Unspecified orders, or when the mask is zero.

Source

pub const fn custom_channels(&self) -> &[ChannelSpec]

Per-channel descriptors for ChannelOrder::Custom layouts; empty otherwise.

Source

pub fn text(&self) -> &str

The backend’s own free-form rendering of this layout — FFmpeg’s av_channel_layout_describe output ("5.1(side)", "3 channels (FL+FR+LFE)"), empty when there is none.

Not a slug: this is what the backend printed, verbatim, and it is the seat that keeps a layout no vocabulary can name from being lost entirely. known_kind is the parsed name; this is the rendering.

Source

pub fn is_empty(&self) -> bool

true when every field is at its absent value — zero channels, Unspecified order, no name, no mask, no custom channels, no rendering. Useful as an “uninitialized” sentinel.

Source

pub const fn with_order(self, v: ChannelOrder) -> Self

Sets the order — consuming builder.

Source

pub const fn with_channels(self, v: u32) -> Self

Sets the channel count — consuming builder.

Source

pub fn with_known_kind(self, v: ChannelLayout) -> Self

Sets the layout’s name — consuming builder.

Source

pub const fn with_native_mask(self, v: Option<u64>) -> Self

Sets the native-order bitmask — consuming builder.

Source

pub fn with_custom_channels(self, v: Vec<ChannelSpec>) -> Self

Sets the custom-order channel list — consuming builder.

Source

pub fn with_text(self, v: impl Into<SmolStr>) -> Self

Sets the backend’s rendering — consuming builder.

Source

pub const fn set_order(&mut self, v: ChannelOrder) -> &mut Self

Sets the order in place.

Source

pub const fn set_channels(&mut self, v: u32) -> &mut Self

Sets the channel count in place.

Source

pub fn set_known_kind(&mut self, v: ChannelLayout) -> &mut Self

Sets the layout’s name in place.

Source

pub const fn set_native_mask(&mut self, v: Option<u64>) -> &mut Self

Sets the native-order bitmask in place.

Source

pub fn set_custom_channels(&mut self, v: Vec<ChannelSpec>) -> &mut Self

Sets the custom-order channel list in place.

Source

pub fn set_text(&mut self, v: impl Into<SmolStr>) -> &mut Self

Sets the backend’s rendering in place.

Trait Implementations§

Source§

impl Arbitrary for ChannelLayoutDescription

Source§

fn arbitrary(__quickcheck_g: &mut Gen) -> Self

Return an arbitrary value. Read more
Source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
Source§

impl<'a> Arbitrary<'a> for ChannelLayoutDescription

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for ChannelLayoutDescription

Source§

fn clone(&self) -> ChannelLayoutDescription

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 Debug for ChannelLayoutDescription

Source§

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

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

impl Default for ChannelLayoutDescription

Source§

fn default() -> Self

Delegates to ChannelLayoutDescription::new with zero channels — the “uninitialized” sentinel Self::is_empty recognises.

Source§

impl DefaultInstance for ChannelLayoutDescription

Available on crate feature buffa only.
Source§

fn default_instance() -> &'static Self

Return a reference to the single default instance of this type.
Source§

impl<'de> Deserialize<'de> for ChannelLayoutDescription

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ChannelLayoutDescription

Source§

impl Hash for ChannelLayoutDescription

Source§

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

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 Message for ChannelLayoutDescription

Available on crate feature buffa only.
Source§

fn compute_size(&self, cache: &mut SizeCache) -> u32

Compute the encoded byte size of this message, recording nested sub-message sizes in cache for write_to to consume. Read more
Source§

fn write_to(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)

Write this message’s encoded bytes to a buffer, consuming nested-message sizes from cache (populated by a prior compute_size call on the same cache). Read more
Source§

fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Processes a single already-decoded tag and its associated field data from buf. Read more
Source§

fn clear(&mut self)

Clear all fields to their default values.
Source§

fn encode(&self, buf: &mut impl EncodeSink)

Compute size, then write. This is the primary encoding API. Read more
Source§

fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>

Encode, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)

Encode using a caller-supplied SizeCache, for reuse across many encodes in a hot loop. Clears the cache first. Read more
Source§

fn try_encode_with_cache( &self, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>

Encode with a caller-supplied SizeCache, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Clears the cache first. Read more
Source§

fn try_encode_bounded( &self, max_bytes: u32, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>

Encode this message into buf only if its encoded size fits within max_bytes, using a single size pass that is then reused for the write. Read more
Source§

fn try_encode_bounded_with_cache( &self, max_bytes: u32, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>

Like try_encode_bounded but reuses an existing SizeCache, clearing it first. Read more
Source§

fn encoded_len(&self) -> u32

Compute the encoded byte size of this message. Read more
Source§

fn try_encoded_len(&self) -> Result<u32, EncodeError>

Compute the encoded byte size, returning an error instead of panicking if it exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_length_delimited(&self, buf: &mut impl EncodeSink)

Encode this message as a length-delimited byte sequence. Read more
Source§

fn try_encode_length_delimited( &self, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>

Encode as a length-delimited byte sequence, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>

Encode this message to a new Vec<u8>. Read more
Source§

fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>

Encode to a new Vec<u8>, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn encode_to_bytes(&self) -> Bytes

Encode this message to a new bytes::Bytes. Read more
Source§

fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>

Encode to a new bytes::Bytes, returning an error instead of panicking if the encoded size exceeds the 2 GiB protobuf limit (MAX_MESSAGE_BYTES). Read more
Source§

fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>
where Self: Sized,

Decode a message from a buffer.
Source§

fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>
where Self: Sized,

Decode a message from a byte slice. Read more
Source§

fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>
where Self: Sized,

Decode a length-delimited message from a buffer. Read more
Source§

fn merge_to_limit( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, limit: usize, ) -> Result<(), DecodeError>

Merge fields from a buffer until buf.remaining() reaches limit. Read more
Source§

fn merge_group( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, field_number: u32, ) -> Result<(), DecodeError>

Merges a group-encoded message from buf, reading fields until an EndGroup tag with the given field_number is encountered. Read more
Source§

fn merge( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Merge fields from a buffer into this message. Read more
Source§

fn merge_from_slice(&mut self, data: &[u8]) -> Result<(), DecodeError>

Merge fields from a byte slice into this message. Read more
Source§

fn merge_length_delimited( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>

Merge fields from a length-delimited sub-message payload into this message. Read more
Source§

impl PartialEq for ChannelLayoutDescription

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for ChannelLayoutDescription

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ChannelLayoutDescription

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.