pub struct ChannelLayoutDescription { /* private fields */ }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:
order— Native / Custom / Ambisonic / Unspecified.channels— total count.known_kind— the layout’s name, as aChannelLayout.ChannelLayout::default(theOther("")absent sentinel) when no well-known shape matches.native_mask—Some(bitmask)forChannelOrder::Native/ChannelOrder::Ambisonic,Noneotherwise.custom_channels— populated forChannelOrder::Customlayouts; oneChannelSpecper channel.text— the backend’s own free-form rendering, e.g. FFmpeg’sav_channel_layout_describeoutput ("5.1(side)","3 channels (FL+FR+LFE)").
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
impl ChannelLayoutDescription
Sourcepub const fn new(channels: u32) -> Self
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.
Sourcepub const fn order(&self) -> ChannelOrder
pub const fn order(&self) -> ChannelOrder
Channel ordering (Native / Custom / Ambisonic / Unspecified).
Sourcepub const fn known_kind(&self) -> &ChannelLayout
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.
Sourcepub const fn native_mask(&self) -> Option<u64>
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.
Sourcepub const fn custom_channels(&self) -> &[ChannelSpec]
pub const fn custom_channels(&self) -> &[ChannelSpec]
Per-channel descriptors for ChannelOrder::Custom layouts; empty
otherwise.
Sourcepub fn text(&self) -> &str
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.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub const fn with_order(self, v: ChannelOrder) -> Self
pub const fn with_order(self, v: ChannelOrder) -> Self
Sets the order — consuming builder.
Sourcepub const fn with_channels(self, v: u32) -> Self
pub const fn with_channels(self, v: u32) -> Self
Sets the channel count — consuming builder.
Sourcepub fn with_known_kind(self, v: ChannelLayout) -> Self
pub fn with_known_kind(self, v: ChannelLayout) -> Self
Sets the layout’s name — consuming builder.
Sourcepub const fn with_native_mask(self, v: Option<u64>) -> Self
pub const fn with_native_mask(self, v: Option<u64>) -> Self
Sets the native-order bitmask — consuming builder.
Sourcepub fn with_custom_channels(self, v: Vec<ChannelSpec>) -> Self
pub fn with_custom_channels(self, v: Vec<ChannelSpec>) -> Self
Sets the custom-order channel list — consuming builder.
Sourcepub fn with_text(self, v: impl Into<SmolStr>) -> Self
pub fn with_text(self, v: impl Into<SmolStr>) -> Self
Sets the backend’s rendering — consuming builder.
Sourcepub const fn set_order(&mut self, v: ChannelOrder) -> &mut Self
pub const fn set_order(&mut self, v: ChannelOrder) -> &mut Self
Sets the order in place.
Sourcepub const fn set_channels(&mut self, v: u32) -> &mut Self
pub const fn set_channels(&mut self, v: u32) -> &mut Self
Sets the channel count in place.
Sourcepub fn set_known_kind(&mut self, v: ChannelLayout) -> &mut Self
pub fn set_known_kind(&mut self, v: ChannelLayout) -> &mut Self
Sets the layout’s name in place.
Sourcepub const fn set_native_mask(&mut self, v: Option<u64>) -> &mut Self
pub const fn set_native_mask(&mut self, v: Option<u64>) -> &mut Self
Sets the native-order bitmask in place.
Sourcepub fn set_custom_channels(&mut self, v: Vec<ChannelSpec>) -> &mut Self
pub fn set_custom_channels(&mut self, v: Vec<ChannelSpec>) -> &mut Self
Sets the custom-order channel list in place.
Trait Implementations§
Source§impl Arbitrary for ChannelLayoutDescription
impl Arbitrary for ChannelLayoutDescription
Source§impl<'a> Arbitrary<'a> for ChannelLayoutDescription
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for ChannelLayoutDescription
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for ChannelLayoutDescription
impl Clone for ChannelLayoutDescription
Source§fn clone(&self) -> ChannelLayoutDescription
fn clone(&self) -> ChannelLayoutDescription
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelLayoutDescription
impl Debug for ChannelLayoutDescription
Source§impl Default for ChannelLayoutDescription
impl Default for ChannelLayoutDescription
Source§fn default() -> Self
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.
impl DefaultInstance for ChannelLayoutDescription
buffa only.Source§fn default_instance() -> &'static Self
fn default_instance() -> &'static Self
Source§impl<'de> Deserialize<'de> for ChannelLayoutDescriptionwhere
ChannelLayoutDescription: Default,
impl<'de> Deserialize<'de> for ChannelLayoutDescriptionwhere
ChannelLayoutDescription: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ChannelLayoutDescription
Source§impl Hash for ChannelLayoutDescription
impl Hash for ChannelLayoutDescription
Source§impl Message for ChannelLayoutDescription
Available on crate feature buffa only.
impl Message for ChannelLayoutDescription
buffa only.Source§fn compute_size(&self, cache: &mut SizeCache) -> u32
fn compute_size(&self, cache: &mut SizeCache) -> u32
cache for write_to to consume. Read moreSource§fn write_to(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
fn write_to(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
cache (populated by a prior
compute_size call on the same cache). Read moreSource§fn merge_field(
&mut self,
tag: Tag,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
) -> Result<(), DecodeError>
fn merge_field( &mut self, tag: Tag, buf: &mut impl Buf, ctx: DecodeContext<'_>, ) -> Result<(), DecodeError>
buf. Read moreSource§fn encode(&self, buf: &mut impl EncodeSink)
fn encode(&self, buf: &mut impl EncodeSink)
Source§fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>
fn try_encode(&self, buf: &mut impl EncodeSink) -> Result<(), EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
fn encode_with_cache(&self, cache: &mut SizeCache, buf: &mut impl EncodeSink)
Source§fn try_encode_with_cache(
&self,
cache: &mut SizeCache,
buf: &mut impl EncodeSink,
) -> Result<(), EncodeError>
fn try_encode_with_cache( &self, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>
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 moreSource§fn try_encode_bounded(
&self,
max_bytes: u32,
buf: &mut impl EncodeSink,
) -> Result<u32, EncodeError>
fn try_encode_bounded( &self, max_bytes: u32, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>
buf only if its encoded size fits within
max_bytes, using a single size pass that is then reused for the write. Read moreSource§fn try_encode_bounded_with_cache(
&self,
max_bytes: u32,
cache: &mut SizeCache,
buf: &mut impl EncodeSink,
) -> Result<u32, EncodeError>
fn try_encode_bounded_with_cache( &self, max_bytes: u32, cache: &mut SizeCache, buf: &mut impl EncodeSink, ) -> Result<u32, EncodeError>
Source§fn encoded_len(&self) -> u32
fn encoded_len(&self) -> u32
Source§fn try_encoded_len(&self) -> Result<u32, EncodeError>
fn try_encoded_len(&self) -> Result<u32, EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn encode_length_delimited(&self, buf: &mut impl EncodeSink)
fn encode_length_delimited(&self, buf: &mut impl EncodeSink)
Source§fn try_encode_length_delimited(
&self,
buf: &mut impl EncodeSink,
) -> Result<(), EncodeError>
fn try_encode_length_delimited( &self, buf: &mut impl EncodeSink, ) -> Result<(), EncodeError>
MAX_MESSAGE_BYTES). Read moreSource§fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>
fn try_encode_to_vec(&self) -> Result<Vec<u8>, EncodeError>
Vec<u8>, returning an error instead of panicking
if the encoded size exceeds the 2 GiB protobuf limit
(MAX_MESSAGE_BYTES). Read moreSource§fn encode_to_bytes(&self) -> Bytes
fn encode_to_bytes(&self) -> Bytes
bytes::Bytes. Read moreSource§fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>
fn try_encode_to_bytes(&self) -> Result<Bytes, EncodeError>
bytes::Bytes, returning an error instead of
panicking if the encoded size exceeds the 2 GiB protobuf limit
(MAX_MESSAGE_BYTES). Read moreSource§fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_from_slice(data: &[u8]) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
fn decode_length_delimited(buf: &mut impl Buf) -> Result<Self, DecodeError>where
Self: Sized,
Source§fn merge_to_limit(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
limit: usize,
) -> Result<(), DecodeError>
fn merge_to_limit( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, limit: usize, ) -> Result<(), DecodeError>
Source§fn merge_group(
&mut self,
buf: &mut impl Buf,
ctx: DecodeContext<'_>,
field_number: u32,
) -> Result<(), DecodeError>
fn merge_group( &mut self, buf: &mut impl Buf, ctx: DecodeContext<'_>, field_number: u32, ) -> Result<(), DecodeError>
buf, reading fields until an
EndGroup tag with the given field_number is encountered. Read more