Struct webrtc::data_channel::RTCDataChannel

source ·
pub struct RTCDataChannel { /* private fields */ }
Expand description

DataChannel represents a WebRTC DataChannel The DataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data

Implementations§

source§

impl RTCDataChannel

source

pub async fn transport(&self) -> Option<Weak<RTCSctpTransport>>

transport returns the SCTPTransport instance the DataChannel is sending over.

source

pub fn on_open(&self, f: OnOpenHdlrFn)

on_open sets an event handler which is invoked when the underlying data transport has been established (or re-established).

source

pub fn on_close(&self, f: OnCloseHdlrFn)

on_close sets an event handler which is invoked when the underlying data transport has been closed.

source

pub fn on_message(&self, f: OnMessageHdlrFn)

on_message sets an event handler which is invoked on a binary message arrival over the sctp transport from a remote peer. OnMessage can currently receive messages up to 16384 bytes in size. Check out the detach API if you want to use larger message sizes. Note that browser support for larger messages is also limited.

source

pub fn on_error(&self, f: OnErrorHdlrFn)

on_error sets an event handler which is invoked when the underlying data transport cannot be read.

source

pub async fn send(&self, data: &Bytes) -> Result<usize>

send sends the binary message to the DataChannel peer

source

pub async fn send_text(&self, s: impl Into<String>) -> Result<usize>

send_text sends the text message to the DataChannel peer

source

pub async fn detach(&self) -> Result<Arc<DataChannel>>

detach allows you to detach the underlying datachannel. This provides an idiomatic API to work with, however it disables the OnMessage callback. Before calling Detach you have to enable this behavior by calling webrtc.DetachDataChannels(). Combining detached and normal data channels is not supported. Please refer to the data-channels-detach example and the pion/datachannel documentation for the correct way to handle the resulting DataChannel object.

source

pub async fn close(&self) -> Result<()>

Close Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer.

source

pub fn label(&self) -> &str

label represents a label that can be used to distinguish this DataChannel object from other DataChannel objects. Scripts are allowed to create multiple DataChannel objects with the same label.

source

pub fn ordered(&self) -> bool

Ordered returns true if the DataChannel is ordered, and false if out-of-order delivery is allowed.

source

pub fn max_packet_lifetime(&self) -> u16

max_packet_lifetime represents the length of the time window (msec) during which transmissions and retransmissions may occur in unreliable mode.

source

pub fn max_retransmits(&self) -> u16

max_retransmits represents the maximum number of retransmissions that are attempted in unreliable mode.

source

pub fn protocol(&self) -> &str

protocol represents the name of the sub-protocol used with this DataChannel.

source

pub fn negotiated(&self) -> bool

negotiated represents whether this DataChannel was negotiated by the application (true), or not (false).

source

pub fn id(&self) -> u16

ID represents the ID for this DataChannel. The value is initially null, which is what will be returned if the ID was not provided at channel creation time, and the DTLS role of the SCTP transport has not yet been negotiated. Otherwise, it will return the ID that was either selected by the script or generated. After the ID is set to a non-null value, it will not change.

source

pub fn ready_state(&self) -> RTCDataChannelState

ready_state represents the state of the DataChannel object.

source

pub async fn buffered_amount(&self) -> usize

buffered_amount represents the number of bytes of application data (UTF-8 text and binary data) that have been queued using send(). Even though the data transmission can occur in parallel, the returned value MUST NOT be decreased before the current task yielded back to the event loop to prevent race conditions. The value does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware. The value of buffered_amount slot will only increase with each call to the send() method as long as the ready_state is open; however, buffered_amount does not reset to zero once the channel closes.

source

pub async fn buffered_amount_low_threshold(&self) -> usize

buffered_amount_low_threshold represents the threshold at which the bufferedAmount is considered to be low. When the bufferedAmount decreases from above this threshold to equal or below it, the bufferedamountlow event fires. buffered_amount_low_threshold is initially zero on each new DataChannel, but the application may change its value at any time. The threshold is set to 0 by default.

source

pub async fn set_buffered_amount_low_threshold(&self, th: usize)

set_buffered_amount_low_threshold is used to update the threshold. See buffered_amount_low_threshold().

source

pub async fn on_buffered_amount_low(&self, f: OnBufferedAmountLowFn)

on_buffered_amount_low sets an event handler which is invoked when the number of bytes of outgoing data becomes lower than the buffered_amount_low_threshold.

Trait Implementations§

source§

impl Default for RTCDataChannel

source§

fn default() -> RTCDataChannel

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V