Enum mediasoup::prelude::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
Regular(RegularDataProducer)
Data producer created on transport other than
DirectTransport
.
Direct(DirectDataProducer)
Data producer created on DirectTransport
.
Implementations
sourceimpl DataProducer
impl DataProducer
sourcepub fn id(&self) -> DataProducerId
pub fn id(&self) -> DataProducerId
Data producer identifier.
sourcepub fn type(&self) -> DataProducerType
pub fn type(&self) -> DataProducerType
The type of the data producer.
sourcepub fn sctp_stream_parameters(&self) -> Option<SctpStreamParameters>
pub fn sctp_stream_parameters(&self) -> Option<SctpStreamParameters>
The SCTP stream parameters (just if the data producer type is Sctp
).
sourcepub async fn get_stats(&self) -> Result<Vec<DataProducerStat>, RequestError>
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).
sourcepub fn on_transport_close<F: FnOnce() + Send + 'static>(
&self,
callback: F
) -> HandlerId
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.
sourcepub fn on_close<F: FnOnce() + Send + 'static>(&self, callback: F) -> HandlerId
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.
sourcepub fn downgrade(&self) -> WeakDataProducer
pub fn downgrade(&self) -> WeakDataProducer
Downgrade DataProducer
to WeakDataProducer
instance.
Trait Implementations
sourceimpl Clone for DataProducer
impl Clone for DataProducer
sourcefn clone(&self) -> DataProducer
fn clone(&self) -> DataProducer
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for DataProducer
impl Debug for DataProducer
sourceimpl From<DirectDataProducer> for DataProducer
impl From<DirectDataProducer> for DataProducer
sourcefn from(producer: DirectDataProducer) -> Self
fn from(producer: DirectDataProducer) -> Self
Converts to this type from the input type.
sourceimpl From<RegularDataProducer> for DataProducer
impl From<RegularDataProducer> for DataProducer
sourcefn from(producer: RegularDataProducer) -> Self
fn from(producer: RegularDataProducer) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl !RefUnwindSafe for DataProducer
impl Send for DataProducer
impl Sync for DataProducer
impl Unpin for DataProducer
impl !UnwindSafe for DataProducer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more