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
impl Finder
Sourcepub fn new(ndi: &NDI, settings: &FinderOptions) -> Result<Self>
pub fn new(ndi: &NDI, settings: &FinderOptions) -> Result<Self>
Sourcepub fn wait_for_sources(&self, timeout: Duration) -> Result<bool>
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
timeout- Maximum time to wait (Duration::ZERO= no wait). Must not exceedcrate::MAX_TIMEOUT(~49.7 days).
§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!");
}Sourcepub fn current_sources(&self) -> Result<Vec<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);
}Sourcepub fn find_sources(&self, timeout: Duration) -> Result<Vec<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
timeout- Discovery window.Duration::ZEROreturns an immediate snapshot. Must not exceedcrate::MAX_TIMEOUT(~49.7 days).
§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§
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.
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.