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>
impl<'rx> MetadataFrameRef<'rx>
Sourcepub fn data(&self) -> &str
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.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Get a zero-copy view of the metadata UTF-8 payload bytes, excluding the SDK trailing NUL terminator.
Sourcepub fn to_owned(&self) -> MetadataFrame
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more