[][src]Struct dusk_uds::UnixDomainSocket

pub struct UnixDomainSocket { /* fields omitted */ }

Boilerplate for UnixListener.

Will be converted from an implementation of ToString, or will receive a PathBuf via the constructor UnixDomainSocket::new.

Methods

impl UnixDomainSocket[src]

pub fn new(path: PathBuf) -> Self[src]

Default constructor. Receives a PathBuf and never fails, because no UnixListener::bind is performed.

pub fn get_state(&self) -> Result<State, IoError>[src]

Returns the current State of the socket.

It's fallible in case the inner RwLock is poisoned.

Also, it's blocking, if there is a concurrent read/write for the state.

pub fn set_state(&self, state: State) -> Result<(), IoError>[src]

Set the current State of the socket.

Same constraints as UnixDomainSocket::get_state

pub fn is_listening(&self) -> Result<bool, IoError>[src]

Check if the current state is State::Listening.

Same constraints as UnixDomainSocket::get_state

pub fn receive_message(&self, message: Message) -> Result<(), IoError>[src]

Will be called by the mpsc channel to process any incoming Message.

pub fn bind<F>(&self, handler: F) -> Result<(), IoError> where
    F: FnOnce(UnixStream, Sender<Message>),
    F: Send + 'static,
    F: Copy + 'static, 
[src]

Will remove the UnixDomainSocket::path, if it exists, so it cant bind properly to that location.

While the state is State::Listening, listen for incoming data.

Should it receive a Message with State::ShouldQuit, it will interrupt the loop only after the next iteration, because the message is handled asynchronously.

If the socket fails, the loop wont be interrupted, and the error will be reported to the log facade.

Minimal example:

use dusk_uds::UnixDomainSocket;

UnixDomainSocket::from("/dev/null").bind(move |_stream, _sender| {
    // Code goes here
}).unwrap_or(());

Trait Implementations

impl<T: ToString> From<T> for UnixDomainSocket[src]

Auto Trait Implementations

Blanket Implementations

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

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

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.

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.

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

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

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