Skip to main content

ProbeContext

Struct ProbeContext 

Source
#[non_exhaustive]
pub struct ProbeContext<'a> { pub tag: &'a CodecTag, pub header: Option<&'a [u8]>, pub packet: Option<&'a [u8]>, pub bits_per_sample: Option<u16>, pub channels: Option<u16>, pub sample_rate: Option<u32>, pub width: Option<u32>, pub height: Option<u32>, }
Expand description

Context passed to a codec’s probe function during tag resolution.

Built by the demuxer from whatever it has already parsed (stream format block, a peek at the first packet, numeric hints like bits_per_sample). Probes read fields directly; the struct is #[non_exhaustive] so additional hints can be added later without breaking codec crates that match on it.

The canonical construction pattern, for a demuxer:

let tag = CodecTag::wave_format(0x0001);
let ctx = ProbeContext::new(&tag)
    .bits(24)
    .channels(2)
    .sample_rate(48_000);

Codec authors read fields like ctx.bits_per_sample / ctx.tag directly — #[non_exhaustive] forbids struct-literal construction from outside this crate but does not restrict field access.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§tag: &'a CodecTag

The tag being resolved — always set.

§header: Option<&'a [u8]>

Raw container-level stream-format blob if available (e.g. WAVEFORMATEX, BITMAPINFOHEADER, MP4 sample-entry bytes, Matroska CodecPrivate). Format is container-specific.

§packet: Option<&'a [u8]>

First packet bytes if the demuxer has already read one. Most demuxers resolve tags at stream-discovery time before any packet exists; this is None in that case.

§bits_per_sample: Option<u16>

Audio: bits per sample (from WAVEFORMATEX, MP4 sample entry, Matroska BitDepth, etc.).

§channels: Option<u16>§sample_rate: Option<u32>§width: Option<u32>§height: Option<u32>

Implementations§

Source§

impl<'a> ProbeContext<'a>

Source

pub fn new(tag: &'a CodecTag) -> Self

Start building a context for tag with every hint field empty.

Source

pub fn header(self, h: &'a [u8]) -> Self

Source

pub fn packet(self, p: &'a [u8]) -> Self

Source

pub fn bits(self, n: u16) -> Self

Source

pub fn channels(self, n: u16) -> Self

Source

pub fn sample_rate(self, n: u32) -> Self

Source

pub fn width(self, n: u32) -> Self

Source

pub fn height(self, n: u32) -> Self

Trait Implementations§

Source§

impl<'a> Clone for ProbeContext<'a>

Source§

fn clone(&self) -> ProbeContext<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for ProbeContext<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ProbeContext<'a>

§

impl<'a> RefUnwindSafe for ProbeContext<'a>

§

impl<'a> Send for ProbeContext<'a>

§

impl<'a> Sync for ProbeContext<'a>

§

impl<'a> Unpin for ProbeContext<'a>

§

impl<'a> UnsafeUnpin for ProbeContext<'a>

§

impl<'a> UnwindSafe for ProbeContext<'a>

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<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> 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 = 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.