Expand description
§use-socket
use-socket provides small helpers for parsing and formatting host-and-port endpoints.
Experimental: this crate is below 0.3.0 and the API may change.
§Example Usage
use use_socket::{format_socket_endpoint, parse_socket_endpoint};
let endpoint = parse_socket_endpoint("[::1]:8080").unwrap();
assert_eq!(endpoint.host, "::1");
assert_eq!(format_socket_endpoint(&endpoint), "[::1]:8080");§Scope
- Parsing host-and-port endpoints.
- Formatting endpoints with proper IPv6 bracket handling.
- Simple host and port splitting helpers.
§Non-goals
- Opening sockets.
- Async socket handling.
- Unix sockets.
- Socket options.
§License
Licensed under MIT OR Apache-2.0.
Structs§
- Socket
Endpoint - Stores a normalized host-and-port endpoint.
Functions§
- format_
socket_ endpoint - Formats a socket endpoint, adding IPv6 brackets when needed.
- is_
host_ port - Returns
truewhen the input is a valid host-and-port endpoint. - is_
ipv4_ socket_ endpoint - Returns
truewhen the endpoint uses an IPv4 host. - is_
ipv6_ socket_ endpoint - Returns
truewhen the endpoint uses an IPv6 host. - parse_
socket_ endpoint - Parses a socket endpoint from common host-and-port forms.
- split_
host_ port - Splits a valid endpoint into host and port components.