anysocket 0.1.0

Socket types that can be either Tcp or Unix Domain
Documentation
  • Coverage
  • 31.58%
    6 out of 19 items documented0 out of 12 items with examples
  • Size
  • Source code size: 13.32 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.33 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Documentation
  • njaard/anysocket
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • njaard

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() {
	// ...
}