Struct iptrie::Ipv6Prefix

source ·
pub struct Ipv6Prefix { /* private fields */ }
Expand description

An Ipv4 prefix similar to Ipv6Net but with trailing bits guaranteed to equal 0

Implementations§

source§

impl Ipv6Prefix

source

pub fn new(addr: Ipv6Addr, len: u8) -> Result<Self, IpPrefixError>

Build a new prefix.

All the bits greater than the prefix length are set to `0``. If the specified length is greater than the maximum allowed, an error is returned.

Example
use std::net::{Ipv4Addr, Ipv6Addr};
    use ipnet::PrefixLenError;
    let ipv4 = "1.2.3.4".parse::<Ipv4Addr>().unwrap();
    let ipv6 = "1:2:3:4::".parse::<Ipv6Addr>().unwrap();

    assert!( Ipv6Prefix::new(ipv6, 78).is_ok());

    assert_eq!( Ipv6Prefix::new(ipv6, 133), Err(IpPrefixError::PrefixLenError));

Trait Implementations§

source§

impl Clone for Ipv6Prefix

source§

fn clone(&self) -> Ipv6Prefix

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Ipv6Prefix

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Ipv6Prefix

source§

fn default() -> Ipv6Prefix

Returns the “default value” for a type. Read more
source§

impl Display for Ipv6Prefix

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Ipv6Addr> for Ipv6Prefix

source§

fn from(value: Ipv6Addr) -> Self

Converts to this type from the input type.
source§

impl From<Ipv6Net> for Ipv6Prefix

source§

fn from(value: Ipv6Net) -> Self

Converts to this type from the input type.
source§

impl From<Ipv6Prefix> for Ipv6Net

source§

fn from(value: Ipv6Prefix) -> Self

Converts to this type from the input type.
source§

impl From<Ipv6Prefix120> for Ipv6Prefix

source§

fn from(value: Ipv6Prefix120) -> Self

Converts to this type from the input type.
source§

impl From<Ipv6Prefix56> for Ipv6Prefix

source§

fn from(value: Ipv6Prefix56) -> Self

Converts to this type from the input type.
source§

impl FromStr for Ipv6Prefix

§

type Err = IpPrefixError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl Hash for Ipv6Prefix

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

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

impl IpPrefix for Ipv6Prefix

§

type Slot = u128

The slot manipulated inside this prefix
source§

fn root() -> Self

Root prefix has a length of 0
source§

fn bitslot(&self) -> Self::Slot

The inner slot as is Read more
source§

fn bitslot_trunc(&self) -> Self::Slot

The inner slot with all the masked bits set to 0. Read more
source§

fn len(&self) -> u8

Length of the prefix. Read more
source§

const MAX_LEN: u8 = 128u8

The maximum allowed length for this prefix
§

type Addr = Ipv6Addr

The underlying ip address (usually Ipv4Addr or Ipv6Addr)
source§

fn network(&self) -> Self::Addr

The address of the network defined by the prefixv Read more
source§

fn bitmask(&self) -> Self::Slot

Mask of the prefix. Read more
source§

impl IpPrefixCovering<Ipv6Addr> for Ipv6Prefix

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Net> for Ipv6Prefix

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Prefix> for Ipv6Net

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Prefix> for Ipv6Prefix120

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Prefix> for Ipv6Prefix56

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Prefix120> for Ipv6Prefix

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl IpPrefixCovering<Ipv6Prefix56> for Ipv6Prefix

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl PartialEq<Ipv6Prefix> for Ipv6Prefix

source§

fn eq(&self, other: &Ipv6Prefix) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Ipv6Prefix> for Ipv6Prefix120

§

type Error = IpPrefixError

The type returned in the event of a conversion error.
source§

fn try_from(value: Ipv6Prefix) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<Ipv6Prefix> for Ipv6Prefix56

§

type Error = IpPrefixError

The type returned in the event of a conversion error.
source§

fn try_from(value: Ipv6Prefix) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for Ipv6Prefix

source§

impl Eq for Ipv6Prefix

source§

impl StructuralEq for Ipv6Prefix

source§

impl StructuralPartialEq for Ipv6Prefix

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<P> IpPrefixCovering<P> for Pwhere P: IpPrefix,

source§

fn covering(&self, other: &P) -> IpPrefixCoverage

source§

fn covers(&self, other: &P) -> bool

Checks the coverage of this prefix against a set of addresses Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.