dusk-uds 0.1.0

Minimalistic boilerplate for UnixListener bindings.
Documentation
# Dusk Unix Domain Sockets

[![Crate](https://img.shields.io/crates/v/dusk-uds.svg)](https://crates.io/crates/dusk-uds)
[![Documentation](https://docs.rs/dusk-uds/badge.svg)](https://docs.rs/dusk-uds)

Minimalistic boilerplate for [`UnixListener`] bindings.

Complies with the log facade.

## Installation

Add this to your `Cargo.toml`:

```toml
[dependencies]
dusk-uds = "0.1"
```

## Example

```rust
use dusk_uds::{Message, State, UnixDomainSocket};
use std::io::{Read, Write};
use std::sync::mpsc;

fn handler<S: Read + Write>(socket: S, sender: mpsc::Sender<Message>) {
    let mut socket = socket;
    let mut buf = [0u8; 4];

    // UnixListener implements Read + Write
    socket.read_exact(&mut buf).unwrap();
    socket.write_all(b"Some reply").unwrap();

    // Ask the listener to stop after the next iteration
    sender
        .send(Message::ChangeState(State::ShouldQuit))
        .unwrap();
}

fn main() {
    // Set the correct path
    // /dev/null will fail, unless your OS is broken :)
    let uds = UnixDomainSocket::from("/dev/null").bind(handler);
    if let Err(_e) = uds {
        // Report
    }
}
```