[−][src]Struct dusk_uds::UnixDomainSocket
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]
pub fn bind<F>(&self, handler: F) -> Result<(), IoError> where
F: FnOnce(UnixStream, Sender<Message>),
F: Send + 'static,
F: Copy + 'static,
[src]
F: FnOnce(UnixStream, Sender<Message>),
F: Send + 'static,
F: Copy + 'static,
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
Auto Trait Implementations
impl !Sync for UnixDomainSocket
impl Send for UnixDomainSocket
impl Unpin for UnixDomainSocket
impl !RefUnwindSafe for UnixDomainSocket
impl !UnwindSafe for UnixDomainSocket
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,