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.
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);
}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 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
timeout- Discovery window.Duration::ZEROreturns an immediate snapshot. Must not exceedcrate::MAX_TIMEOUT(~49.7 days).
§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§
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.
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.