Struct LocalSocketListener

Source
pub struct LocalSocketListener { /* private fields */ }
Expand description

A local socket server, listening for connections.

§Examples

Implementations§

Source§

impl LocalSocketListener

Source

pub fn bind<'a>(name: impl ToLocalSocketName<'a>) -> Result<Self>

Creates a socket server with the specified local socket name.

Source

pub fn accept(&self) -> Result<LocalSocketStream>

Listens for incoming connections to the socket, blocking until a client is connected.

See incoming for a convenient way to create a main loop for a server.

Source

pub fn incoming(&self) -> Incoming<'_>

Creates an infinite iterator which calls accept() with each iteration. Used together with for loops to conveniently create a main loop for a socket server.

Source

pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>

Enables or disables the nonblocking mode for the listener. By default, it is disabled.

In nonblocking mode, calling accept and iterating through incoming will immediately return a WouldBlock error if there is no client attempting to connect at the moment instead of blocking until one arrives.

§Platform-specific behavior
§Windows

The nonblocking mode will be also be set for the streams produced by accept and incoming, both existing and new ones.

Trait Implementations§

Source§

impl Debug for LocalSocketListener

Source§

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

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

impl<'a> From<&'a LocalSocketListener> for Incoming<'a>

Source§

fn from(listener: &'a LocalSocketListener) -> Self

Converts to this type from the input type.

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> 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> To for T
where T: ?Sized,

Source§

fn to<T>(self) -> T
where Self: Into<T>,

Converts to T by calling Into<T>::into.
Source§

fn try_to<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Tries to convert to T by calling TryInto<T>::try_into.
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.