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.

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 is complete and deterministic.

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 discovered within the window. 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§

impl Send for Finder

§Safety

The NDI SDK documentation states that find operations are thread-safe. NDIlib_find_create_v2, NDIlib_find_wait_for_sources, and NDIlib_find_get_sources can be called from multiple threads. The Finder struct only holds an opaque pointer returned by the SDK and does not perform any mutations that could cause data races.

Source§

impl Sync for Finder

§Safety

The NDI SDK documentation guarantees thread-safety for find operations. Multiple threads can safely call methods on a shared Finder instance as the SDK handles all necessary synchronization internally.

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.