mediasoup::data_producer

Enum DataProducer

Source
#[non_exhaustive]
pub enum DataProducer { Regular(RegularDataProducer), Direct(DirectDataProducer), }
Expand description

A data producer represents an endpoint capable of injecting data messages into a mediasoup Router.

A data producer can use SCTP (AKA DataChannel) to deliver those messages, or can directly send them from the Rust application if the data producer was created on top of a DirectTransport.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Regular(RegularDataProducer)

Data producer created on transport other than DirectTransport.

§

Direct(DirectDataProducer)

Data producer created on DirectTransport.

Implementations§

Source§

impl DataProducer

Source

pub fn id(&self) -> DataProducerId

Data producer identifier.

Source

pub fn transport(&self) -> &Arc<dyn Transport>

Transport to which data producer belongs.

Source

pub fn type(&self) -> DataProducerType

The type of the data producer.

Source

pub fn sctp_stream_parameters(&self) -> Option<SctpStreamParameters>

The SCTP stream parameters (just if the data producer type is Sctp).

Source

pub fn paused(&self) -> bool

Whether the DataProducer is paused.

Source

pub fn label(&self) -> &String

The data producer label.

Source

pub fn protocol(&self) -> &String

The data producer sub-protocol.

Source

pub fn app_data(&self) -> &AppData

Custom application data.

Source

pub fn closed(&self) -> bool

Whether the data producer is closed.

Source

pub async fn get_stats(&self) -> Result<Vec<DataProducerStat>, RequestError>

Returns current statistics of the data producer.

Check the RTC Statistics section for more details (TypeScript-oriented, but concepts apply here as well).

Source

pub async fn pause(&self) -> Result<(), RequestError>

Pauses the data producer (no message is sent to its associated data consumers). Calls DataConsumer::on_data_producer_pause callback on all its associated data consumers.

Source

pub async fn resume(&self) -> Result<(), RequestError>

Resumes the data producer (messages are sent to its associated data consumers). Calls DataConsumer::on_data_producer_resume callback on all its associated data consumers.

Source

pub fn on_transport_close<F: FnOnce() + Send + 'static>( &self, callback: F, ) -> HandlerId

Callback is called when the transport this data producer belongs to is closed for whatever reason. The producer itself is also closed. A on_data_producer_close callback is called on all its associated consumers.

Source

pub fn on_pause<F: Fn() + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId

Callback is called when the data producer is paused.

Source

pub fn on_resume<F: Fn() + Send + Sync + 'static>( &self, callback: F, ) -> HandlerId

Callback is called when the data producer is resumed.

Source

pub fn on_close<F: FnOnce() + Send + 'static>(&self, callback: F) -> HandlerId

Callback is called when the producer is closed for whatever reason.

NOTE: Callback will be called in place if data producer is already closed.

Source

pub fn downgrade(&self) -> WeakDataProducer

Downgrade DataProducer to WeakDataProducer instance.

Trait Implementations§

Source§

impl Clone for DataProducer

Source§

fn clone(&self) -> DataProducer

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataProducer

Source§

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

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

impl From<DirectDataProducer> for DataProducer

Source§

fn from(producer: DirectDataProducer) -> Self

Converts to this type from the input type.
Source§

impl From<RegularDataProducer> for DataProducer

Source§

fn from(producer: RegularDataProducer) -> Self

Converts to this type from the input type.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.