Skip to main content

Router

Struct Router 

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

A native routing source. Dropping it removes its advertisement.

§Threading

A router is Send but not Sync: it may be moved to another thread, and is used by one thread at a time. To keep one in state that several threads share, put it in a Mutex, which is Sync because the router is Send.

Implementations§

Source§

impl Router

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

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

Source

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

Source

pub fn clear_connection_metadata(&mut self) -> Result<()>

Forget the metadata added with add_connection_metadata.

§Errors

As for add_connection_metadata.

Trait Implementations§

Source§

impl Debug for Router

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Router

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

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.