pub struct SubnetMask { /* private fields */ }
Expand description

A bitmask which represents the boundary between the Network part and Host part of an IPv4 address.

Implementations§

source§

impl SubnetMask

source

pub const fn new(prefix_length: PrefixLength<Ipv4>) -> Self

Constructs a new SubnetMask.

source

pub fn octets(&self) -> [u8; 4]

Returns a byte-array representation of the SubnetMask in Network (Big-Endian) byte-order.

source

pub fn ones(&self) -> u8

Returns the count of the set high-order bits of the SubnetMask.

source

pub fn apply_to(&self, target: &Ipv4Addr) -> Ipv4Addr

Returns the network address resulting from masking the argument.

source

pub fn broadcast_of(&self, target: &Ipv4Addr) -> Ipv4Addr

Computes the broadcast address for the argument.

source

pub fn subnet_size(&self) -> u32

Returns the size of the subnet defined by this mask.

Trait Implementations§

source§

impl Clone for SubnetMask

source§

fn clone(&self) -> SubnetMask

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 SubnetMask

source§

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

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

impl<'de> Deserialize<'de> for SubnetMask

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl FidlCompatible<Ipv4Address> for SubnetMask

§

type FromError = Error

§

type IntoError = Infallible

source§

fn try_from_fidl(fidl: Ipv4Address) -> Result<Self, Self::FromError>

source§

fn try_into_fidl(self) -> Result<Ipv4Address, Self::IntoError>

source§

impl From<SubnetMask> for Ipv4Addr

source§

fn from(value: SubnetMask) -> Self

Converts to this type from the input type.
source§

impl From<SubnetMask> for PrefixLength<Ipv4>

source§

fn from(value: SubnetMask) -> Self

Converts to this type from the input type.
source§

impl PartialEq for SubnetMask

source§

fn eq(&self, other: &SubnetMask) -> 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 Serialize for SubnetMask

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<Ipv4Addr> for SubnetMask

§

type Error = Error

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

fn try_from(mask: Ipv4Addr) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for SubnetMask

source§

impl StructuralPartialEq for SubnetMask

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Encode<Ambiguous1> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T> Encode<Ambiguous2> for T

§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _offset: usize, _depth: Depth ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Cast the given object into a dyn std::any::Any.
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
§

impl<F, C> IntoFidlExt<F> for C
where C: FidlCompatible<F, IntoError = Infallible>,

§

fn into_fidl(self) -> F

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where 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, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

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

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,