Struct web_socket::server::Data

source ·
pub struct Data<'a, Stream> {
    pub ty: DataType,
    /* private fields */
}
Expand description

It represent a single websocket message.

Fields§

§ty: DataType

A DataType value indicating the type of the data.

Implementations§

source§

impl<RW: Unpin + AsyncBufRead + AsyncWrite> Data<'_, RW>

source

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

Pull some bytes from this source into the specified buffer, returning how many bytes were read.

source

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

Read the exact number of bytes required to fill buf.

source

pub async fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<()>

It is a wrapper around the Self::read_to_end_with_limit function with a default limit of 16 MB.

source

pub async fn read_to_end_with_limit( &mut self, buf: &mut Vec<u8>, limit: usize ) -> Result<()>

Reads data until it reaches a specified limit or end of stream.

source§

impl<RW: Unpin + AsyncBufRead + AsyncWrite> Data<'_, RW>

source

pub fn len(&self) -> usize

Length of the “Payload data” in bytes.

source

pub fn fin(&self) -> bool

Indicates that this is the final fragment in a message. The first fragment MAY also be the final fragment.

source

pub async fn flash(&mut self) -> Result<()>

Flushes this output stream, ensuring that all intermediately buffered contents reach their destination.

source

pub async fn send(&mut self, data: impl Message) -> Result<()>

send message to a endpoint by writing it to a WebSocket stream.

Auto Trait Implementations§

§

impl<'a, Stream> !RefUnwindSafe for Data<'a, Stream>

§

impl<'a, Stream> Send for Data<'a, Stream>where Stream: Send,

§

impl<'a, Stream> Sync for Data<'a, Stream>where Stream: Sync,

§

impl<'a, Stream> Unpin for Data<'a, Stream>

§

impl<'a, Stream> !UnwindSafe for Data<'a, Stream>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.