Skip to main content

MetadataFrame

Struct MetadataFrame 

Source
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

Source

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.

Source

pub fn with_timecode(self, timecode: Timecode) -> Self

Return this frame with timecode.

Source

pub fn data(&self) -> &str

Get the metadata text.

Source

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

Get the UTF-8 payload bytes, excluding the trailing NUL.

Source

pub fn to_owned(&self) -> Self

Copy this frame into an independently owned metadata frame.

Source

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.

Source

pub fn into_data(self) -> String

Consume the frame and return the owned metadata text.

Source

pub fn timecode(&self) -> Timecode

Get the timecode.

A new frame starts with Timecode::SYNTHESIZE; a received frame keeps the timecode it arrived with.

Source

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.

Source

pub fn set_timecode(&mut self, timecode: Timecode)

Set the timecode.

Trait Implementations§

Source§

impl Clone for MetadataFrame

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MetadataFrame

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for MetadataFrame

Source§

impl Hash for MetadataFrame

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl MetadataSource for MetadataFrame

Source§

fn data(&self) -> &str

The UTF-8 text without its trailing NUL. Empty metadata returns "".
Source§

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

The payload bytes, excluding the trailing NUL.
Source§

fn timecode(&self) -> Timecode

The source timecode, including Timecode::SYNTHESIZE when requested.
Source§

fn to_owned(&self) -> MetadataFrame

Copy the text and timecode into an independently owned frame.
Source§

fn copy_into(&self, destination: &mut MetadataFrame)

Copy into an existing frame, reusing its text allocation when its capacity holds the text and trailing NUL, even when the length changes.
Source§

impl PartialEq for MetadataFrame

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MetadataFrame

Auto Trait Implementations§

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.