pub struct NDI { /* private fields */ }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.
Create handles with NDI::new or Clone::clone; direct construction is private
so every handle owns a reference to the initialized runtime.
§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 droppedImplementations§
Source§impl NDI
impl NDI
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new NDI instance.
This checked constructor is thread-safe and can be called from multiple threads. It initializes the runtime when necessary; otherwise it acquires another runtime reference. Cloning a live handle also acquires a reference. The runtime is destroyed when the last handle is dropped, including handles retained internally by senders, receivers, and finders.
§Errors
Returns Error::InitializationFailed if the NDI SDK fails to initialize
or the process has exhausted the runtime handle reference count.
§Examples
let ndi = NDI::new()?;
// Use NDI operations...Sourcepub fn is_supported_cpu() -> bool
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");
}Sourcepub fn is_running() -> bool
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
impl Clone for NDI
Source§fn clone(&self) -> Self
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)
fn clone_from(&mut self, source: &Self)
source. Read more