anysocket

Crates.ioanysocket
lib.rsanysocket
version0.1.0
sourcesrc
created_at2020-08-31 21:48:15.080037
updated_at2020-08-31 21:48:15.080037
descriptionSocket types that can be either Tcp or Unix Domain
homepage
repositoryhttps://github.com/njaard/anysocket
max_upload_size
id283241
size13,700
project-freta (github:microsoft:project-freta)

documentation

https://tiny-http.github.io/tiny-http/tiny_http/index.html

README

This library exposes new types that wrap either TcpSocket or UnixSocket types.

This library compiles on Windows but doesn't support UnixSocket types.

Before:

if addr.starts_with("unix:") {
	let socket = UnixListener::bind(&addr["unix:".len() ..]).expect("binding");
	while let Ok(socket) = socket.accept() {
		// ...
	}
}
else {
	let socket = TcpListener::bind(addr).expect("binding");;
	while let Ok(socket) = socket.accept() {
		// ...
	}
}

After:

let socket = addr.bind_any().expect("binding");
while let Ok(socket) = socket.accept() {
	// ...
}

Commit count: 2

cargo fmt