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

Skip to main content

Crate use_port

Crate use_port 

Source
Expand description

§use-port

use-port provides small helpers for parsing port numbers, classifying port ranges, and mapping a few common services to default ports.

Experimental: this crate is below 0.3.0 and the API may change.

§Example Usage

use use_port::{common_port_name, parse_port, port_range, PortRange};

let port = parse_port("443").unwrap();

assert_eq!(port.value, 443);
assert_eq!(port_range(port.value), PortRange::System);
assert_eq!(common_port_name(port.value), Some("https"));

§Scope

  • Port parsing from strings.
  • Port range classification.
  • Small common service-to-port lookup tables.

§Non-goals

  • Port scanning.
  • Socket binding.
  • Service discovery.

§License

Licensed under MIT OR Apache-2.0.

Structs§

Port
Stores a validated port number.

Enums§

PortRange
Classifies a port into the standard IANA port ranges.

Functions§

common_port_name
Looks up a common service name for a port.
default_port_for_service
Looks up a default port for a common service name.
is_dynamic_port
Returns true when the port is in the dynamic range.
is_registered_port
Returns true when the port is in the registered range.
is_system_port
Returns true when the port is in the system range.
is_valid_port
Returns true when the input fits into a valid u16 port number.
parse_port
Parses a port number from text.
port_range
Returns the IANA port range for the provided port.