Skip to main content

Ndi

Struct Ndi 

Source
pub struct Ndi { /* private fields */ }
Expand description

A handle to the started NDI runtime.

Every finder, sender and receiver is created from an Ndi handle, and NDI stays started while any handle exists: those objects each retain one, and Clone::clone and Runtime::initialize add more. Dropping the last handle stops NDI but leaves the selected library loaded, so NDI can be started again. Ndi::process_lifetime keeps it started until the process exits.

Ndi::new selects the default runtime and starts it in one call. To inspect a runtime before starting it, or to choose which one is loaded, use Runtime::select and then Runtime::initialize.

§Examples

use grafton_ndi::Ndi;

let ndi = Ndi::new()?;

// NDI stays started for as long as any handle exists.
let another = ndi.clone();
drop(ndi);
assert!(Ndi::is_running());

// Dropping the last handle stops it.
drop(another);

Implementations§

Source§

impl Ndi

Source

pub fn timestamp(&self) -> Result<SdkTimestamp>

Read the selected SDK’s current timestamp, retaining its clock semantics.

Requires the NDI 6.4 timestamp helper. Missing capability is an error; this never falls back to SystemTime or Instant.

Source§

impl Ndi

Source

pub fn new() -> Result<Self>

Select the default NDI runtime and start it.

This is Runtime::select with the default RuntimeOptions followed by Runtime::initialize. It is thread-safe: the first handle starts NDI and later calls add handles to the running runtime. See the search and trust policy before selecting a runtime in a service or elevated process.

§Errors

Returns Error::RuntimeLoadFailed if no usable runtime library is found in the search order. Its crate::LoadFailure distinguishes code that loaded and was refused from locations that could not be opened. Returns Error::RuntimeConflict if native loading re-enters runtime selection on the same thread. Returns Error::UnsupportedCpu if the runtime does not start because this CPU cannot run it, and Error::InitializationFailed if it does not start for another reason or the count of handles is exhausted.

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

pub fn with_options(options: &RuntimeOptions) -> Result<Self>

Select the NDI runtime options describe and start it.

This is Runtime::select followed by Runtime::initialize.

§Errors

Returns the errors of those two steps. A failed selection or start can be retried; once selection has succeeded, every later call uses the selected runtime and reports Error::RuntimeConflict for options it does not meet, with a typed crate::SelectionConflict. A crate::LoadFailure retains the structured attempts when loading fails.

§Examples
use grafton_ndi::{RuntimeOptions, SdkEdition, Ndi};

let ndi = Ndi::with_options(&RuntimeOptions::default().edition(SdkEdition::Advanced))?;
Source

pub fn runtime(&self) -> Runtime

The selected implementation this handle keeps started.

§Examples
let ndi = Ndi::new()?;
// A second handle from the same runtime, without selecting again.
let another = ndi.runtime().initialize()?;
Source

pub fn info(&self) -> &'static RuntimeInfo

The selected implementation’s identity; see Runtime::info.

Source

pub fn capabilities(&self) -> &'static Capabilities

What the selected implementation supports; see Runtime::capabilities.

Source

pub fn require_feature(&self, feature: RuntimeFeature) -> Result<()>

Reject an unavailable operation before passing newer inputs to the SDK.

§Errors

Returns Error::UnsupportedCapability naming the capability and why the selected runtime or this build cannot provide it.

Source

pub fn process_lifetime(&self) -> ProcessLifetimeRuntime

Retain an initialized runtime reference until process exit.

This is an irreversible, process-wide opt-in. It does not change ordinary reference-counted teardown unless this method is explicitly called.

Source

pub fn is_running() -> bool

Whether NDI is started, by this or any other handle in the process.

This only reads the current state: it never selects or loads a runtime, and is false before one has been selected.

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

Trait Implementations§

Source§

impl Clone for Ndi

Source§

fn clone(&self) -> Self

Acquires another reference to the active runtime.

§Panics

Panics if the runtime handle reference count is exhausted. The original handle and runtime remain valid.

1.0.0 (const: unstable) · 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
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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 = !

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.