Skip to main content

MetadataFrameRef

Struct MetadataFrameRef 

Source
pub struct MetadataFrameRef<'rx> { /* private fields */ }
Expand description

A zero-copy borrowed metadata frame.

This type wraps an RAII guard that owns the NDI frame buffer lifetime, exposing a safe, zero-copy view of the metadata string. The frame is automatically freed when dropped via NDIlib_recv_free_metadata.

Key characteristics:

  • Zero allocations: References NDI SDK buffers directly
  • Zero copies: No string duplication
  • RAII lifetime: Exactly one free per frame, enforced at compile time
  • Not Send: Prevents accidental cross-thread use of FFI buffers

§Examples

// Zero-copy capture
if let Some(frame) = receiver.metadata().try_capture_ref(Duration::from_millis(1000))? {
    println!("Metadata: {}", frame.data());

    // Frame is freed here when `frame` goes out of scope
}

Implementations§

Source§

impl<'rx> MetadataFrameRef<'rx>

Source

pub fn timecode(&self) -> i64

Get the timecode.

Source

pub fn data(&self) -> &str

Get a zero-copy view of the metadata text.

This returns a reference directly into the NDI SDK’s buffer. No allocation or string copying is performed.

Source

pub fn as_bytes(&self) -> &[u8]

Get a zero-copy view of the metadata UTF-8 payload bytes, excluding the SDK trailing NUL terminator.

Source

pub fn to_owned(&self) -> MetadataFrame

Convert this borrowed frame to an owned MetadataFrame.

This performs a string copy, allowing the frame to outlive the NDI buffer and be sent across threads.

Trait Implementations§

Source§

impl<'rx> Debug for MetadataFrameRef<'rx>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'rx> Freeze for MetadataFrameRef<'rx>

§

impl<'rx> RefUnwindSafe for MetadataFrameRef<'rx>

§

impl<'rx> !Send for MetadataFrameRef<'rx>

§

impl<'rx> !Sync for MetadataFrameRef<'rx>

§

impl<'rx> Unpin for MetadataFrameRef<'rx>

§

impl<'rx> UnsafeUnpin for MetadataFrameRef<'rx>

§

impl<'rx> UnwindSafe for MetadataFrameRef<'rx>

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