Skip to main content

Finder

Struct Finder 

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

Discovers NDI sources on the network.

Finder provides methods to discover and monitor NDI sources. It maintains a background thread that continuously updates the list of available sources.

§Examples

let ndi = NDI::new()?;
let options = FinderOptions::builder().show_local_sources(true).build();
let finder = Finder::new(&ndi, &options)?;

// Wait for initial discovery
if finder.wait_for_sources(Duration::from_secs(5))? {
    let sources = finder.current_sources()?;
    for source in sources {
        println!("Found: {}", source);
    }
}

Implementations§

Source§

impl Finder

Source

pub fn new(ndi: &NDI, settings: &FinderOptions) -> Result<Self>

Creates a new source finder with the specified settings.

§Arguments
  • ndi - The NDI instance (cloned internally to keep the runtime alive)
  • settings - Configuration for source discovery
§Errors

Returns an error if the finder cannot be created, typically due to invalid settings or network issues.

Source

pub fn wait_for_sources(&self, timeout: Duration) -> Result<bool>

Waits for the source list to change.

This method blocks until the list of discovered sources changes or the timeout expires. Use this to efficiently monitor for source changes.

§Arguments
§Returns

true if the source list changed, false if the timeout expired.

§Errors

Returns Error::InvalidConfiguration if timeout exceeds crate::MAX_TIMEOUT.

§Examples
// Wait up to 5 seconds for changes
if finder.wait_for_sources(Duration::from_secs(5))? {
    println!("Source list changed!");
}
Source

pub fn current_sources(&self) -> Result<Vec<Source>>

Returns the current list of discovered sources (snapshot).

This method uses NDIlib_find_get_current_sources which provides a snapshot of the current source list without any additional network discovery. Concurrent snapshots on this finder are serialized until all source names and addresses have been copied into owned Rust values.

Available since NDI SDK 6.0.

§Returns

A vector of currently known sources. May be empty if no sources are found.

§Examples
// Get current snapshot of sources
let sources = finder.current_sources()?;

for source in sources {
    println!("Current source: {}", source);
}
Source

pub fn find_sources(&self, timeout: Duration) -> Result<Vec<Source>>

Discovers sources for up to timeout, returning the complete set.

This honors the full timeout window and returns every source observed within it. Unlike a single wait_for_sources followed by a snapshot — which returns on the first source-list change and so can miss responders that announce late on staggered or unicast (IP-hint-only) networks — enumeration here retains each source observed during the window.

For an immediate, non-blocking snapshot of already-known sources use current_sources; to resolve a single specific host use SourceCache::find_by_host.

§Arguments
§Returns

Every source observed within the window, in first-observed order. Identity includes the name and the complete address (including its variant); a changed descriptor is returned as a distinct source. Network discovery cannot guarantee observation of every source. May be empty if none appear.

§Errors

Returns Error::InvalidConfiguration if timeout exceeds crate::MAX_TIMEOUT.

§Examples
// Discover for up to 5 seconds, then list everything found
let sources = finder.find_sources(Duration::from_secs(5))?;

for source in sources {
    println!("Found: {}", source);
}

Trait Implementations§

Source§

impl Drop for Finder

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
Source§

impl Send for Finder

§Safety

The SDK finder handle may be moved between threads. Its runtime and creation strings remain alive with it, and destruction requires exclusive ownership.

Source§

impl Sync for Finder

§Safety

The SDK forbids concurrent NDIlib_find_get_current_sources calls on one instance and invalidates its returned buffers on the next call. sources_lock serializes those calls through the complete deep copy into owned Sources. Waiting for source changes does not invalidate those buffers; destruction requires exclusive access through Drop.

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