struct PortRanges(Vec<PortRange>);Expand description
A collection of port ranges in a sorted order.
Please use this when storing multiple port ranges because it optimizies them storage wise.
Tuple Fields§
§0: Vec<PortRange>Implementations§
Source§impl PortRanges
impl PortRanges
Sourcefn new() -> Self
fn new() -> Self
Creates a new PortRanges collection with no elements in it.
Sourcefn push_ordered(&mut self, item: PortRange) -> Result<(), PolicyError>
fn push_ordered(&mut self, item: PortRange) -> Result<(), PolicyError>
Adds a new range into this PortRanges.
The ranges must be valid, nonoverlapping, and pushed in a monotonically increasing order,
meaning that inserting 400-500,450-600 or 400-500,500-600 are
invalid, whereas 400-500,501-600 and 400-500,501-600 are.
Sourcefn contains(&self, port: u16) -> bool
fn contains(&self, port: u16) -> bool
Checks whether port is contained in a range.
Whether this means if port is allowed or rejected depends on the
surroundings (such as which field this PortRage is in,
or an associated RuleKind).
Sourcefn inverted(&self) -> PortRanges
fn inverted(&self) -> PortRanges
Returns an inverted PortRanges.
For example, a PortRanges of 80-443 would become 1-79,444-65535.
Sourcefn invert(&mut self)
fn invert(&mut self)
Inverts a PortRanges in place
For example, a PortRanges of 80-443 would become 1-79,444-65535.
Sourcefn display(&self) -> Option<impl Display + '_>
fn display(&self) -> Option<impl Display + '_>
If set of ranges is non-empty, returns a string representation
We don’t provide a normal Display impl, because it would have to
emit the empty string for an empty range, which would be quite odd.
When displaying accept/reject ranges, the caller needs to
choose between prepending accept and prepending reject.
Trait Implementations§
Source§impl Clone for PortRanges
impl Clone for PortRanges
Source§fn clone(&self) -> PortRanges
fn clone(&self) -> PortRanges
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PortRanges
impl Debug for PortRanges
Source§impl Default for PortRanges
impl Default for PortRanges
Source§fn default() -> PortRanges
fn default() -> PortRanges
impl Eq for PortRanges
Source§impl FromIterator<u16> for PortRanges
impl FromIterator<u16> for PortRanges
Source§impl FromStr for PortRanges
impl FromStr for PortRanges
Source§impl Hash for PortRanges
impl Hash for PortRanges
Source§impl ItemArgumentParseable for PortRanges
impl ItemArgumentParseable for PortRanges
Source§fn from_args<'s>(args: &mut ArgumentStream<'s>) -> Result<Self, ArgumentError>
fn from_args<'s>(args: &mut ArgumentStream<'s>) -> Result<Self, ArgumentError>
PortRanges argument parser which is odd because port ranges are
syntactically a single argument although semantically multiple ones.
Source§impl PartialEq for PortRanges
impl PartialEq for PortRanges
Source§fn eq(&self, other: &PortRanges) -> bool
fn eq(&self, other: &PortRanges) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PortRanges
Auto Trait Implementations§
impl Freeze for PortRanges
impl RefUnwindSafe for PortRanges
impl Send for PortRanges
impl Sync for PortRanges
impl Unpin for PortRanges
impl UnsafeUnpin for PortRanges
impl UnwindSafe for PortRanges
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§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