Enum fluvio_ws_stream_wasm::WsEvent[][src]

pub enum WsEvent {
    Open,
    Error,
    Closing,
    Closed(CloseEvent),
    WsErr(WsErr),
}
Expand description

Events related to the WebSocket. You can filter like:

use
{
  ws_stream_wasm       :: *                        ,
  pharos               :: *                        ,
  wasm_bindgen         :: UnwrapThrowExt           ,
  wasm_bindgen_futures :: futures_0_3::spawn_local ,
  futures              :: stream::StreamExt        ,
};

let program = async
{
  let (mut ws, _wsio) = WsMeta::connect( "127.0.0.1:3012", None ).await

     .expect_throw( "assume the connection succeeds" );

  // The Filter type comes from the pharos crate.
  //
  let mut evts = ws.observe( Filter::Pointer( WsEvent::is_closed ).into() );

  ws.close().await;

  // Note we will only get the closed event here, the WsEvent::Closing has been filtered out.
  //
  assert!( evts.next().await.unwrap_throw().is_closed () );
};

spawn_local( program );

Variants

Open

The connection is now Open and ready for use.

Error

An error happened on the connection. For more information about when this event occurs, see the HTML Living Standard. Since the browser is not allowed to convey any information to the client code as to why an error happened (for security reasons), as described in the HTML specification, there usually is no extra information available. That’s why this event has no data attached to it.

Closing

The connection has started closing, but is not closed yet. You shouldn’t try to send messages over it anymore. Trying to do so will result in an error.

Closed(CloseEvent)

The connection was closed. The enclosed CloseEvent has some extra information.

WsErr(WsErr)

An error happened, not on the connection, but inside ws_stream_wasm. This currently happens when an incoming message can not be converted to Rust types, eg. a String message with invalid encoding.

Implementations

impl WsEvent[src]

pub fn is_open(&self) -> bool[src]

Predicate indicating whether this is a WsEvent::Open event. Can be used as a filter for the event stream obtained with pharos::Observable::observe on WsMeta.

pub fn is_err(&self) -> bool[src]

Predicate indicating whether this is a WsEvent::Error event. Can be used as a filter for the event stream obtained with pharos::Observable::observe on WsMeta.

pub fn is_closing(&self) -> bool[src]

Predicate indicating whether this is a WsEvent::Closing event. Can be used as a filter for the event stream obtained with pharos::Observable::observe on WsMeta.

pub fn is_closed(&self) -> bool[src]

Predicate indicating whether this is a WsEvent::Closed event. Can be used as a filter for the event stream obtained with pharos::Observable::observe on WsMeta.

pub fn is_ws_err(&self) -> bool[src]

Predicate indicating whether this is a WsEvent::WsErr event. Can be used as a filter for the event stream obtained with pharos::Observable::observe on WsMeta.

Trait Implementations

impl Clone for WsEvent[src]

fn clone(&self) -> WsEvent[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for WsEvent[src]

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

Formats the value using the given formatter. Read more

impl Observable<WsEvent> for WsMeta[src]

type Error = PharErr

The error type that is returned if observing is not possible. Read more

fn observe(
    &mut self,
    options: ObserveConfig<WsEvent>
) -> Observe<'_, WsEvent, Self::Error>
[src]

Add an observer to the observable. Options allow chosing the channel type and to filter events with a predicate. Read more

impl PartialEq<WsEvent> for WsEvent[src]

fn eq(&self, other: &WsEvent) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &WsEvent) -> bool[src]

This method tests for !=.

impl Eq for WsEvent[src]

impl StructuralEq for WsEvent[src]

impl StructuralPartialEq for WsEvent[src]

Auto Trait Implementations

impl RefUnwindSafe for WsEvent

impl Send for WsEvent

impl Sync for WsEvent

impl Unpin for WsEvent

impl UnwindSafe for WsEvent

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.