Skip to main content

Connecting

Struct Connecting 

Source
pub struct Connecting<S> { /* private fields */ }
Expand description

A WebSocket connection in the handshake phase.

Drive the handshake by calling poll() when the socket is ready. Returns Client<S> when complete.

Check wants_read() / wants_write() to determine which readiness event to wait for in your event loop.

§Usage

use nexus_web::ws::{Connecting, ClientBuilder};

let tcp = TcpStream::connect("exchange.com:443")?;
tcp.set_nonblocking(true)?;
let mut connecting = ClientBuilder::new()
    .begin_connect(tcp, "wss://exchange.com/ws")?;

// In your event loop:
loop {
    // ... poll for socket readiness ...
    if let Some(ws) = connecting.poll()? {
        // Handshake complete — ws.recv() is now available
        break;
    }
}

Implementations§

Source§

impl<S: Read + Write> Connecting<S>

Source

pub fn poll(&mut self) -> Result<Option<Client<S>>, Error>

Drive the handshake forward. Non-blocking.

Returns Ok(None) while in progress, Ok(Some(ws)) when the connection is ready and recv() can be called.

Call when the socket is readable or writable (check wants_read() / wants_write()).

On WouldBlock, returns Ok(None) — call again when the socket is ready.

Source

pub fn wants_write(&self) -> bool

Whether the handshake needs to write to the socket.

Source

pub fn wants_read(&self) -> bool

Whether the handshake needs to read from the socket.

Source

pub fn stream(&self) -> &S

Access the underlying stream (for mio registration).

Source

pub fn stream_mut(&mut self) -> &mut S

Mutable access to the underlying stream.

Trait Implementations§

Source§

impl<S> Drop for Connecting<S>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<S> Freeze for Connecting<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for Connecting<S>

§

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

§

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

§

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

§

impl<S> UnsafeUnpin for Connecting<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for Connecting<S>

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> Same for T

Source§

type Output = T

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