Enum WsFrame

Source
pub enum WsFrame {
    Text(String),
    Binary(Vec<u8>),
    Ping(Vec<u8>),
    Pong(Vec<u8>),
    Close(CloseData),
}
Expand description

enumerates the different websocket message types

Variants§

§

Text(String)

utf8 text

§

Binary(Vec<u8>)

a string of bytes

§

Ping(Vec<u8>)

a ping message, content must be < 125 bytes

§

Pong(Vec<u8>)

a pong message, content must be < 125 bytes

§

Close(CloseData)

a close message, with a websocket close code https://www.iana.org/assignments/websocket/websocket.xml#close-code-number

Implementations§

Source§

impl WsFrame

Source

pub fn assume<O: Into<Self>>(&mut self, oth: O)

consume another frame-type instance

Source

pub fn as_bytes(&self) -> &[u8]

get frame data out as byte slice

Source

pub fn as_str(&self) -> Cow<'_, str>

get frame data out as a string slice

Source

pub fn is_text(&self) -> bool

true if frame type is WsFrame::Text

Source

pub fn is_binary(&self) -> bool

true if frame type is WsFrame::Binary

Source

pub fn is_ping(&self) -> bool

true if frame type is WsFrame::Ping

Source

pub fn is_pong(&self) -> bool

true if frame type is WsFrame::Pong

Source

pub fn is_close(&self) -> bool

true if frame type is WsFrame::Close

Trait Implementations§

Source§

impl Clone for WsFrame

Source§

fn clone(&self) -> WsFrame

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 WsFrame

Source§

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

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

impl Default for WsFrame

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&[u8]> for WsFrame

Source§

fn from(b: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for WsFrame

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Message> for WsFrame

Source§

fn from(m: Message) -> Self

Converts to this type from the input type.
Source§

impl From<String> for WsFrame

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for WsFrame

Source§

fn from(b: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<WsFrame> for Message

Source§

fn from(m: WsFrame) -> Self

Converts to this type from the input type.
Source§

impl<Sub: InStreamStd> InStream<&mut WsFrame, WsFrame> for InStreamWss<Sub>

Source§

const URL_SCHEME: &'static str = SCHEME

your implementation should work with a single url scheme/protocol if you need to support multiple (i.e. ws:// vs wss://) consider using macros/code generation to DRY
Source§

fn raw_connect<C: InStreamConfig>(url: &Url2, config: C) -> Result<Self>

create a new connection / stream of this type. this function does the actual work of connecting, but it is recommended your struct provide a wrapper with a concrete config type
Source§

fn check_ready(&mut self) -> Result<bool>

process the stream to see if any remaining handshake items can be completed returns true if stream is set-up and ready to send/receive note that you can write before this function returns true but your messages may be buffered / sent later
Source§

fn remote_url(&self) -> Url2

access the remote url this connection represents
Source§

fn read(&mut self, data: &mut WsFrame) -> Result<usize>

non-blocking read. if R is an array-type, success result is number of elements read otherwise it is 1
Source§

fn write(&mut self, data: WsFrame) -> Result<usize>

buffered write. Implementors should buffer data on WouldBlock
Source§

fn flush(&mut self) -> Result<()>

blocking flush all pending buffered write data.
Source§

impl<Sub: InStreamListenerStd> InStreamListener<&mut WsFrame, WsFrame> for InStreamListenerWss<Sub>

Source§

type Stream = InStreamWss<<Sub as InStreamListenerStd>::StreamStd>

Source§

fn raw_bind<C: InStreamConfig>(url: &Url2, config: C) -> Result<Self>

begin listening on the given url spec this function does the actual work of binding, but it is recommended your struct provide a wrapper with a concrete config type
Source§

fn binding(&self) -> Url2

access the url for the bound interface
Source§

fn accept( &mut self, ) -> Result<<Self as InStreamListener<&mut WsFrame, WsFrame>>::Stream>

attempt to accept a stream/socket from this binding may return Err(ErrorKind::WouldBlock.into())

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Source§

type Output = T

Should always be Self
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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T