pub struct PortRange {
    pub lo: u16,
    pub hi: u16,
}
Expand description

A PortRange is a set of consecutively numbered TCP or UDP ports.

Example

use tor_netdoc::types::policy::PortRange;

let r: PortRange = "22-8000".parse().unwrap();
assert!(r.contains(128));
assert!(r.contains(22));
assert!(r.contains(8000));

assert!(! r.contains(21));
assert!(! r.contains(8001));

Fields

lo: u16

The first port in this range.

hi: u16

The last port in this range.

Implementations

Create a port range containing all ports.

Create a new PortRange.

The Portrange contains all ports between lo and hi inclusive.

Returns None if lo is greater than hi, or if either is zero.

Return true if a port is in this range.

Return true if this range contains all ports.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

A PortRange is displayed as a number if it contains a single port, and as a start point and end point separated by a dash if it contains more than one port.

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.