Struct webrtc_data::data_channel::DataChannel

source ·
pub struct DataChannel {
    pub config: Config,
    /* private fields */
}
Expand description

DataChannel represents a data channel

Fields§

§config: Config

Implementations§

source§

impl DataChannel

source

pub fn new(stream: Arc<Stream>, config: Config) -> Self

source

pub async fn dial( association: &Arc<Association>, identifier: u16, config: Config ) -> Result<Self, Error>

Dial opens a data channels over SCTP

source

pub async fn accept<T>( association: &Arc<Association>, config: Config, existing_channels: &[T] ) -> Result<Self, Error>
where T: Borrow<Self>,

Accept is used to accept incoming data channels over SCTP

source

pub async fn client(stream: Arc<Stream>, config: Config) -> Result<Self, Error>

Client opens a data channel over an SCTP stream

source

pub async fn server(stream: Arc<Stream>, config: Config) -> Result<Self, Error>

Server accepts a data channel over an SCTP stream

source

pub async fn read(&self, buf: &mut [u8]) -> Result<usize, Error>

Read reads a packet of len(p) bytes as binary data.

See sctp::stream::Stream::read_sctp.

source

pub async fn read_data_channel( &self, buf: &mut [u8] ) -> Result<(usize, bool), Error>

ReadDataChannel reads a packet of len(p) bytes. It returns the number of bytes read and true if the data read is a string.

See sctp::stream::Stream::read_sctp.

source

pub fn messages_sent(&self) -> usize

MessagesSent returns the number of messages sent

source

pub fn messages_received(&self) -> usize

MessagesReceived returns the number of messages received

source

pub fn bytes_sent(&self) -> usize

BytesSent returns the number of bytes sent

source

pub fn bytes_received(&self) -> usize

BytesReceived returns the number of bytes received

source

pub fn stream_identifier(&self) -> u16

StreamIdentifier returns the Stream identifier associated to the stream.

source

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

Write writes len(p) bytes from p as binary data

source

pub async fn write_data_channel( &self, data: &Bytes, is_string: bool ) -> Result<usize, Error>

WriteDataChannel writes len(p) bytes from p

source

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

Close closes the DataChannel and the underlying SCTP stream.

source

pub fn buffered_amount(&self) -> usize

BufferedAmount returns the number of bytes of data currently queued to be sent over this stream.

source

pub fn buffered_amount_low_threshold(&self) -> usize

BufferedAmountLowThreshold returns the number of bytes of buffered outgoing data that is considered “low.” Defaults to 0.

source

pub fn set_buffered_amount_low_threshold(&self, threshold: usize)

SetBufferedAmountLowThreshold is used to update the threshold. See BufferedAmountLowThreshold().

source

pub fn on_buffered_amount_low(&self, f: OnBufferedAmountLowFn)

OnBufferedAmountLow sets the callback handler which would be called when the number of bytes of outgoing data buffered is lower than the threshold.

Trait Implementations§

source§

impl AsRef<DataChannel> for PollDataChannel

source§

fn as_ref(&self) -> &DataChannel

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for DataChannel

source§

fn clone(&self) -> DataChannel

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 DataChannel

source§

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

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

impl Default for DataChannel

source§

fn default() -> DataChannel

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

§

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

§

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