enum SocketState {
Initial,
Bound(SocketAddr),
Listening(TcpListener),
Connecting(TcpStream),
Connected(TcpStream),
}Variants§
Initial
No syscall after socket has been made.
Bound(SocketAddr)
The bind syscall has been called on the socket.
This is only reachable from the SocketState::Initial state.
Listening(TcpListener)
The listen syscall has been called on the socket.
This is only reachable from the SocketState::Bound state.
Connecting(TcpStream)
The connect syscall has been called and we weren’t yet able
to ensure the connection is established. This is only reachable
from the SocketState::Initial state.
Connected(TcpStream)
The connect syscall has been called on the socket and
we ensured that the connection is established, or
the socket was created by the accept syscall.
For a socket created using the connect syscall, this is
only reachable from the SocketState::Connecting state.
Implementations§
Source§impl SocketState
impl SocketState
Sourcepub fn try_set_connected(&mut self) -> Result<(), SocketIoError>
pub fn try_set_connected(&mut self) -> Result<(), SocketIoError>
If the socket is currently in SocketState::Connecting, try to ensure
that the connection is established by first checking that [TcpStream::take_error]
doesn’t return an error and then by checking that [TcpStream::peer_addr]
returns the address of the connected peer.
If the connection is established or the socket is in any other state,
Ok is returned.
Important: On Windows hosts this function can only be used to ensure a socket is connected
after a [Interest::WRITABLE] event was received.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SocketState
impl RefUnwindSafe for SocketState
impl Send for SocketState
impl Sync for SocketState
impl Unpin for SocketState
impl UnsafeUnpin for SocketState
impl UnwindSafe for SocketState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes
Size for each variant:
Initial: 0 bytesBound: 32 bytesListening: 8 bytesConnecting: 8 bytesConnected: 8 bytes