Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate use_socket

Crate use_socket 

Source
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§

SocketEndpoint
Stores a normalized host-and-port endpoint.

Functions§

format_socket_endpoint
Formats a socket endpoint, adding IPv6 brackets when needed.
is_host_port
Returns true when the input is a valid host-and-port endpoint.
is_ipv4_socket_endpoint
Returns true when the endpoint uses an IPv4 host.
is_ipv6_socket_endpoint
Returns true when 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.