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 through its receiver or sender’s matching metadata release.
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
Send + Sync: Captured metadata can be processed on a scoped worker thread
§Examples
// Zero-copy capture
if let Some(frame) = receiver.capture_metadata_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.
Sourcepub fn copy_into(&self, destination: &mut MetadataFrame)
pub fn copy_into(&self, destination: &mut MetadataFrame)
Copy text and timecode into an existing owned frame. Reuses its text allocation when its capacity holds the text and trailing NUL.
Trait Implementations§
Source§impl<'rx> Debug for MetadataFrameRef<'rx>
impl<'rx> Debug for MetadataFrameRef<'rx>
Source§impl<'a> MetadataSource for MetadataFrameRef<'a>
impl<'a> MetadataSource for MetadataFrameRef<'a>
Source§fn timecode(&self) -> Timecode
fn timecode(&self) -> Timecode
Timecode::SYNTHESIZE when requested.