pub struct PortRange {
lo: u16,
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: u16The first port in this range.
hi: u16The last port in this range.
Implementations§
Source§impl PortRange
impl PortRange
Sourceconst fn new_unchecked(lo: u16, hi: u16) -> Self
const fn new_unchecked(lo: u16, hi: u16) -> Self
Create a new port range spanning from lo to hi, asserting that the correct invariants hold.
Sourcepub fn new(lo: u16, hi: u16) -> Option<Self>
pub fn new(lo: u16, hi: u16) -> Option<Self>
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.
Sourcepub fn from_range(r: RangeInclusive<u16>) -> Option<Self>
pub fn from_range(r: RangeInclusive<u16>) -> Option<Self>
Create a new PortRange from a RangeInclusive
Returns None if the range is ill-formed, or contains zero.
Sourcepub fn to_range(self) -> RangeInclusive<u16> ⓘ
pub fn to_range(self) -> RangeInclusive<u16> ⓘ
Create a new PortRange from a RangeInclusive
Returns None if the range is ill-formed, or contains zero.
Sourcefn compare_to_port(&self, port: u16) -> Ordering
fn compare_to_port(&self, port: u16) -> Ordering
Helper for binary search: compare this range to a port.
This range is “equal” to all ports that it contains. It is “greater” than all ports that precede its starting point, and “less” than all ports that follow its ending point.
Trait Implementations§
impl Copy for PortRange
Source§impl Display for PortRange
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.
impl Display for PortRange
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.
impl Eq for PortRange
impl NormalItemArgument for PortRange
impl StructuralPartialEq for PortRange
Auto Trait Implementations§
impl Freeze for PortRange
impl RefUnwindSafe for PortRange
impl Send for PortRange
impl Sync for PortRange
impl Unpin for PortRange
impl UnsafeUnpin for PortRange
impl UnwindSafe for PortRange
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more