Struct postgres_inet::MaskedIpAddr [−][src]
pub struct MaskedIpAddr { /* fields omitted */ }An IP address with a netmask.
Methods
impl MaskedIpAddr[src]
impl MaskedIpAddrpub fn new<I: Into<IpAddr>>(addr: I, mask: u8) -> MaskedIpAddr[src]
pub fn new<I: Into<IpAddr>>(addr: I, mask: u8) -> MaskedIpAddrCreates a new MaskedIpAddr from components.
Do not pass an addr with bits set to the right of the netmask if you
intend to insert this into a postgres cidr field.
Panics
Panics if the netmask is greater than 32 for an IPv4 address, or is greater than 128 for an IPv6 address.
Examples
To represent an address:
let ip = Ipv4Addr::new(192, 0, 2, 142); MaskedIpAddr::new(ip, 32);
To represent a network:
let network = Ipv6Addr::new(0x2001, 0x0DB8, 0, 0, 0, 0, 0, 0); MaskedIpAddr::new(network, 32);
pub fn is_unspecified(&self) -> bool[src]
pub fn is_unspecified(&self) -> boolReturns true for the special 'unspecified' address.
See the documentation for Ipv4Addr::is_unspecified and
Ipv6Addr::is_unspecified for more details.
Examples
assert!(MaskedIpAddr::new(Ipv4Addr::new(0, 0, 0, 0), 32).is_unspecified()); assert!(MaskedIpAddr::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0), 128).is_unspecified());
pub fn is_loopback(&self) -> bool[src]
pub fn is_loopback(&self) -> boolReturns true if this is a loopback address.
See the documentation for Ipv4Addr::is_loopback and
Ipv6Addr::is_loopback for more details.
Examples
assert!(MaskedIpAddr::new(Ipv4Addr::new(127, 0, 0, 1), 32).is_loopback()); assert!(MaskedIpAddr::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 128).is_loopback());
pub fn is_multicast(&self) -> bool[src]
pub fn is_multicast(&self) -> boolReturns true if this is a multicast address.
See the documentation for Ipv4Addr::is_multicast and
Ipv6Addr::is_multicast for more details.
Examples
assert!(MaskedIpAddr::new(Ipv4Addr::new(224, 254, 0, 0), 32).is_multicast()); assert!(MaskedIpAddr::new(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0), 128).is_multicast());
pub fn is_ipv4(&self) -> bool[src]
pub fn is_ipv4(&self) -> boolReturns true if this address is an IPv4 address, and false otherwise.
Examples
assert!(MaskedIpAddr::new(Ipv4Addr::new(203, 0, 113, 6), 32).is_ipv4()); assert!(!MaskedIpAddr::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 128).is_ipv4());
pub fn is_ipv6(&self) -> bool[src]
pub fn is_ipv6(&self) -> boolReturns true if this address is an IPv6 address, and false otherwise.
Examples
assert!(!MaskedIpAddr::new(Ipv4Addr::new(203, 0, 113, 6), 32).is_ipv6()); assert!(MaskedIpAddr::new(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0), 128).is_ipv6());
pub fn address(&self) -> IpAddr[src]
pub fn address(&self) -> IpAddrReturns the contained IP address.
Examples
let ip = Ipv4Addr::new(192, 0, 2, 142); assert_eq!(MaskedIpAddr::new(ip, 32).address(), ip); let network = Ipv6Addr::new(0x2001, 0x0DB8, 0, 0, 0, 0, 0, 0); assert_eq!(MaskedIpAddr::new(network, 32).address(), network);
pub fn netmask(&self) -> u8[src]
pub fn netmask(&self) -> u8Returns the contained netmask.
Examples
assert_eq!(MaskedIpAddr::new(Ipv4Addr::new(192, 0, 2, 142), 32).netmask(), 32); assert_eq!(MaskedIpAddr::new(Ipv6Addr::new(0x2001, 0x0DB8, 0, 0, 0, 0, 0, 0), 64).netmask(), 64);
pub fn into_inner(self) -> (IpAddr, u8)[src]
pub fn into_inner(self) -> (IpAddr, u8)Consumes the MaskedIpAddr, returning the IP address and netmask.
Examples
let network = Ipv4Addr::new(198, 51, 100, 0); assert_eq!(MaskedIpAddr::new(network, 24).into_inner(), (network.into(), 24));
Trait Implementations
impl Copy for MaskedIpAddr[src]
impl Copy for MaskedIpAddrimpl Clone for MaskedIpAddr[src]
impl Clone for MaskedIpAddrfn clone(&self) -> MaskedIpAddr[src]
fn clone(&self) -> MaskedIpAddrReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Eq for MaskedIpAddr[src]
impl Eq for MaskedIpAddrimpl PartialEq for MaskedIpAddr[src]
impl PartialEq for MaskedIpAddrfn eq(&self, other: &MaskedIpAddr) -> bool[src]
fn eq(&self, other: &MaskedIpAddr) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &MaskedIpAddr) -> bool[src]
fn ne(&self, other: &MaskedIpAddr) -> boolThis method tests for !=.
impl Hash for MaskedIpAddr[src]
impl Hash for MaskedIpAddrfn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash<__H: Hasher>(&self, state: &mut __H)Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, Feeds a slice of this type into the given [Hasher]. Read more
impl PartialOrd for MaskedIpAddr[src]
impl PartialOrd for MaskedIpAddrfn partial_cmp(&self, other: &MaskedIpAddr) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &MaskedIpAddr) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &MaskedIpAddr) -> bool[src]
fn lt(&self, other: &MaskedIpAddr) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &MaskedIpAddr) -> bool[src]
fn le(&self, other: &MaskedIpAddr) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &MaskedIpAddr) -> bool[src]
fn gt(&self, other: &MaskedIpAddr) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &MaskedIpAddr) -> bool[src]
fn ge(&self, other: &MaskedIpAddr) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for MaskedIpAddr[src]
impl Ord for MaskedIpAddrfn cmp(&self, other: &MaskedIpAddr) -> Ordering[src]
fn cmp(&self, other: &MaskedIpAddr) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl From<Ipv4Addr> for MaskedIpAddr[src]
impl From<Ipv4Addr> for MaskedIpAddrfn from(ipv4: Ipv4Addr) -> MaskedIpAddr[src]
fn from(ipv4: Ipv4Addr) -> MaskedIpAddrPerforms the conversion.
impl From<Ipv6Addr> for MaskedIpAddr[src]
impl From<Ipv6Addr> for MaskedIpAddrfn from(ipv6: Ipv6Addr) -> MaskedIpAddr[src]
fn from(ipv6: Ipv6Addr) -> MaskedIpAddrPerforms the conversion.
impl From<IpAddr> for MaskedIpAddr[src]
impl From<IpAddr> for MaskedIpAddrfn from(ip: IpAddr) -> MaskedIpAddr[src]
fn from(ip: IpAddr) -> MaskedIpAddrPerforms the conversion.
impl From<MaskedIpAddr> for IpAddr[src]
impl From<MaskedIpAddr> for IpAddrfn from(mip: MaskedIpAddr) -> IpAddr[src]
fn from(mip: MaskedIpAddr) -> IpAddrPerforms the conversion.
impl From<[u8; 4]> for MaskedIpAddr[src]
impl From<[u8; 4]> for MaskedIpAddrimpl From<[u8; 16]> for MaskedIpAddr[src]
impl From<[u8; 16]> for MaskedIpAddrimpl From<[u16; 8]> for MaskedIpAddr[src]
impl From<[u16; 8]> for MaskedIpAddrimpl Display for MaskedIpAddr[src]
impl Display for MaskedIpAddrfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl Debug for MaskedIpAddr[src]
impl Debug for MaskedIpAddrfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl FromSql for MaskedIpAddr[src]
impl FromSql for MaskedIpAddrfn from_sql(
_: &Type,
raw: &[u8]
) -> Result<Self, Box<Error + Sync + Send + 'static>>[src]
fn from_sql(
_: &Type,
raw: &[u8]
) -> Result<Self, Box<Error + Sync + Send + 'static>>Creates a new value of this type from a buffer of data of the specified Postgres Type in its binary format. Read more
fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> boolDetermines if a value of this type can be created from the specified Postgres Type. Read more
fn from_sql_null(ty: &Type) -> Result<Self, Box<Error + 'static + Sync + Send>>
fn from_sql_null(ty: &Type) -> Result<Self, Box<Error + 'static + Sync + Send>>Creates a new value of this type from a NULL SQL value. Read more
fn from_sql_nullable(
ty: &Type,
raw: Option<&[u8]>
) -> Result<Self, Box<Error + 'static + Sync + Send>>
fn from_sql_nullable(
ty: &Type,
raw: Option<&[u8]>
) -> Result<Self, Box<Error + 'static + Sync + Send>>A convenience function that delegates to from_sql and from_sql_null depending on the value of raw. Read more
impl ToSql for MaskedIpAddr[src]
impl ToSql for MaskedIpAddrfn to_sql(
&self,
ty: &Type,
w: &mut Vec<u8>
) -> Result<IsNull, Box<Error + Sync + Send>>[src]
fn to_sql(
&self,
ty: &Type,
w: &mut Vec<u8>
) -> Result<IsNull, Box<Error + Sync + Send>>Converts the value of self into the binary format of the specified Postgres Type, appending it to out. Read more
fn accepts(ty: &Type) -> bool
fn accepts(ty: &Type) -> boolDetermines if a value of this type can be converted to the specified Postgres Type. Read more
fn to_sql_checked(
&self,
ty: &Type,
out: &mut Vec<u8>
) -> Result<IsNull, Box<Error + Sync + Send>>
fn to_sql_checked(
&self,
ty: &Type,
out: &mut Vec<u8>
) -> Result<IsNull, Box<Error + Sync + Send>>An adaptor method used internally by Rust-Postgres. Read more
impl FromStr for MaskedIpAddr[src]
impl FromStr for MaskedIpAddrAuto Trait Implementations
impl Send for MaskedIpAddr
impl Send for MaskedIpAddrimpl Sync for MaskedIpAddr
impl Sync for MaskedIpAddr