pub struct MetadataFrame { /* private fields */ }Expand description
Owned UTF-8 metadata text and its timecode.
NDI expects XML when sending; callers are responsible for XML syntax. Text cannot contain NUL bytes and is limited to 4 MiB including the SDK terminator.
§Examples
use grafton_ndi::{MetadataFrame, Timecode};
let frame = MetadataFrame::new("<tally on_program=\"true\"/>")?
.with_timecode(Timecode::from_ticks(0));
assert_eq!(frame.data(), "<tally on_program=\"true\"/>");
assert_eq!(frame.timecode().ticks(), 0);Implementations§
Source§impl MetadataFrame
impl MetadataFrame
Sourcepub fn new(data: impl Into<String>) -> Result<Self, Rejected<String>>
pub fn new(data: impl Into<String>) -> Result<Self, Rejected<String>>
Create a metadata frame from UTF-8 text, with
Timecode::SYNTHESIZE.
An owned string retains its allocation when there is capacity for
the trailing NUL, and otherwise grows once.
§Errors
Returns the unchanged text in Rejected. Its reason is
Error::InvalidCString if data contains an interior NUL byte
or Error::InvalidFrame if the SDK metadata length would exceed the
crate’s metadata size limit.
The NulError retains only the prefix through the first NUL; use
Rejected::into_inner for the whole original string.
Sourcepub fn with_timecode(self, timecode: Timecode) -> Self
pub fn with_timecode(self, timecode: Timecode) -> Self
Return this frame with timecode.
Sourcepub fn copy_into(&self, destination: &mut Self)
pub fn copy_into(&self, destination: &mut Self)
Copy text and timecode into an existing frame. Reuses its text allocation when its capacity holds the text and trailing NUL.
Sourcepub fn timecode(&self) -> Timecode
pub fn timecode(&self) -> Timecode
Get the timecode.
A new frame starts with Timecode::SYNTHESIZE; a received frame
keeps the timecode it arrived with.
Sourcepub fn set_data(
&mut self,
data: impl Into<String>,
) -> Result<(), Rejected<String>>
pub fn set_data( &mut self, data: impl Into<String>, ) -> Result<(), Rejected<String>>
Replace the metadata text.
§Errors
Returns the unchanged text in Rejected. Its reason is
Error::InvalidCString if data contains an interior NUL byte
or Error::InvalidFrame if the SDK metadata length would exceed the
crate’s metadata size limit. The frame is unchanged.
The NulError retains only the prefix through the first NUL; use
Rejected::into_inner for the whole original string.
Sourcepub fn set_timecode(&mut self, timecode: Timecode)
pub fn set_timecode(&mut self, timecode: Timecode)
Set the timecode.
Trait Implementations§
Source§impl Clone for MetadataFrame
impl Clone for MetadataFrame
Source§impl Debug for MetadataFrame
impl Debug for MetadataFrame
impl Eq for MetadataFrame
Source§impl Hash for MetadataFrame
impl Hash for MetadataFrame
Source§impl MetadataSource for MetadataFrame
impl MetadataSource for MetadataFrame
Source§fn timecode(&self) -> Timecode
fn timecode(&self) -> Timecode
Timecode::SYNTHESIZE when requested.