Struct WebsocketConnection

Source
pub struct WebsocketConnection<S> { /* private fields */ }

Implementations§

Source§

impl<S> WebsocketConnection<S>
where S: AsyncRead + AsyncWrite + Unpin,

Source

pub async fn new(uri: Uri, socket: S) -> Result<Self>

Construct a websocket stream to a pre-established connection socket.

§Errors

Returns an error if the websocket handshake fails.

Source

pub fn poll_read_next( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<ServerOp, WebsocketReadError>>

Source

pub async fn read_next(&mut self) -> Result<ServerOp, WebsocketReadError>

Reads the next ServerOp.

§Errors

It returns an error if the content cannot be decoded or if an I/O error occurs.

Source

pub fn should_flush(&self) -> bool

Source

pub fn may_enqueue_more_ops(&mut self) -> bool

Source

pub fn enqueue_write_op(&mut self, item: &ClientOp)

Enqueue item to be written.

Source

pub fn poll_flush(&mut self, cx: &mut Context<'_>) -> Poll<Result<()>>

Source

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

Flush any buffered writes to the connection

§Errors

Returns an error if flushing fails

Source

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

Shutdown the connection

§Errors

Returns an error if shutting down the connection fails. Implementations usually ignore this error.

Trait Implementations§

Source§

impl<S: Debug> Debug for WebsocketConnection<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S> !Freeze for WebsocketConnection<S>

§

impl<S> RefUnwindSafe for WebsocketConnection<S>
where S: RefUnwindSafe,

§

impl<S> Send for WebsocketConnection<S>
where S: Send,

§

impl<S> Sync for WebsocketConnection<S>
where S: Sync,

§

impl<S> Unpin for WebsocketConnection<S>
where S: Unpin,

§

impl<S> UnwindSafe for WebsocketConnection<S>
where S: UnwindSafe,

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