Skip to main content

NDI

Struct NDI 

Source
pub struct NDI;
Expand description

Manages the NDI runtime lifecycle.

The NDI struct is the entry point for all NDI operations. It ensures the NDI runtime is properly initialized and cleaned up. Multiple instances can exist simultaneously - they share the same underlying runtime through reference counting.

§Examples

use grafton_ndi::NDI;

// Create an NDI instance
let ndi = NDI::new()?;

// The runtime stays alive as long as any NDI instance exists
let ndi2 = ndi.clone(); // Cheap reference-counted clone

// Runtime is automatically cleaned up when all instances are dropped

Implementations§

Source§

impl NDI

Source

pub fn new() -> Result<Self>

Creates a new NDI instance.

This method is the single entry point for creating NDI instances. It is thread-safe and can be called from multiple threads. The first call initializes the NDI runtime, subsequent calls increment a reference count. When the last instance is dropped, the runtime is automatically destroyed.

§Errors

Returns Error::InitializationFailed if the NDI SDK fails to initialize.

§Examples
let ndi = NDI::new()?;
// Use NDI operations...
Source

pub fn is_supported_cpu() -> bool

Checks if the current CPU is supported by the NDI SDK.

The NDI SDK requires certain CPU features (e.g., SSE4.2 on x86_64).

§Examples
if grafton_ndi::NDI::is_supported_cpu() {
    println!("CPU is supported by NDI");
} else {
    eprintln!("CPU lacks required features for NDI");
}
Source

pub fn version() -> Result<String>

Returns the version string of the NDI runtime.

§Errors

Returns an error if the version string cannot be retrieved or contains invalid UTF-8.

§Examples
match NDI::version() {
    Ok(version) => println!("NDI version: {}", version),
    Err(e) => eprintln!("Failed to get version: {}", e),
}
Source

pub fn is_running() -> bool

Checks if the NDI runtime is currently initialized.

This can be useful for diagnostic purposes or conditional initialization.

§Examples
if grafton_ndi::NDI::is_running() {
    println!("NDI runtime is active");
}

Trait Implementations§

Source§

impl Clone for NDI

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NDI

Source§

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

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

impl Drop for NDI

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for NDI

§

impl RefUnwindSafe for NDI

§

impl Send for NDI

§

impl Sync for NDI

§

impl Unpin for NDI

§

impl UnsafeUnpin for NDI

§

impl UnwindSafe for NDI

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