Skip to content

Instantly share code, notes, and snippets.

View asonix's full-sized avatar
🦁

asonix asonix

🦁
View GitHub Profile
@asonix
asonix / bind.rs
Last active August 8, 2019 22:46
Edit: It works now. stdin and stdout need their own processes
use failure::Error;
use futures::{Future, Stream};
use tokio::{io::AsyncRead, net::UnixListener};
fn main() -> Result<(), Error> {
let listener = UnixListener::bind("socket.sock")?;
tokio::run(
listener
.incoming()
@asonix
asonix / traits.rs
Last active December 5, 2017 20:27
Example of using traits with structs
trait HasAStringInIt {
fn get_str(&self) -> &str;
fn set_str(&mut self, new_string: String);
}
struct File {
name: String,
contents: Vec<u8>,
}