pub struct Router { /* private fields */ }Expand description
Implementations§
Source§impl Router
impl Router
Sourcepub fn new(ndi: &Ndi, options: &RouterOptions) -> Result<Self>
pub fn new(ndi: &Ndi, options: &RouterOptions) -> Result<Self>
Create and advertise a routing source that routes to nothing yet.
§Errors
Returns crate::Error::UnsupportedCapability when the selected runtime has no
routing support, or the
options carry an Advanced configuration that the runtime or this build
cannot take; crate::Error::InvalidCString when the name contains a
NUL byte; crate::Error::InvalidInput when the group list is empty or
a group is empty or contains a comma or NUL; and
crate::Error::NativeOperationFailed when the SDK creates no source.
Sourcepub fn set_route(&mut self, source: &Source) -> Result<()>
pub fn set_route(&mut self, source: &Source) -> Result<()>
Route connected and future receivers to source.
§Errors
Returns crate::Error::NativeOperationFailed when the SDK rejects
the change.
Sourcepub fn clear_route(&mut self) -> Result<()>
pub fn clear_route(&mut self) -> Result<()>
Stop routing to any source. Receivers stay connected to the router.
§Errors
Returns crate::Error::NativeOperationFailed when the SDK rejects the change.
Sourcepub fn connection_count(&self) -> Result<u32>
pub fn connection_count(&self) -> Result<u32>
Count the receivers currently connected to this router without waiting. This count does not establish progress of their media streams.
§Errors
Returns crate::Error::UnexpectedSdkResult when the SDK reports a
negative count.
Sourcepub fn wait_for_connection(
&self,
timeout: Duration,
) -> Result<Option<NonZeroU32>>
pub fn wait_for_connection( &self, timeout: Duration, ) -> Result<Option<NonZeroU32>>
Wait up to timeout for at least one receiver to connect.
Returns the connected count, or None when the timeout expires.
A zero timeout checks the current count without waiting.
§Errors
Returns crate::Error::InvalidInput when timeout exceeds
crate::MAX_TIMEOUT, and crate::Error::UnexpectedSdkResult when
the SDK reports a negative count.
Sourcepub fn source(&self) -> Result<Source>
pub fn source(&self) -> Result<Source>
The source descriptor this router is advertised under, which receivers connect to.
§Errors
Returns crate::Error::NativeOperationFailed when the SDK supplies no
descriptor, or one that names neither a source nor an address, and
crate::Error::UnexpectedSdkResult when its name or address is longer than
the 4 MiB available for one SDK string, including its terminator.
crate::Error::InvalidUtf8 reports an invalid name or address.
crate::Error::AllocationFailed reports a failed text buffer reservation.
See crate::Finder::current_sources for allocation behavior of
shared source owners.
Source§impl Router
impl Router
Sourcepub fn add_connection_metadata<S: MetadataSource + ?Sized>(
&mut self,
metadata: &S,
) -> Result<()>
pub fn add_connection_metadata<S: MetadataSource + ?Sized>( &mut self, metadata: &S, ) -> Result<()>
Send metadata to every connected receiver now, and to each receiver
that connects later.
The router keeps its own copy of owned or captured text; the input may be released immediately afterward, even for future connections.
§Errors
Error::UnsupportedCapability
without an Advanced runtime (or in a build without the Advanced SDK).