pub struct Prefix {
pub protocol: AFI,
pub length: u8,
pub prefix: Vec<u8>,
}
Expand description
Represents a generic prefix. For example an IPv4 prefix or IPv6 prefix.
Fields§
§protocol: AFI
IP version for prefix (v4|v6)
length: u8
Prefix Mask length in bits
prefix: Vec<u8>
Prefix Octets
Implementations§
Trait Implementations§
Source§impl From<&Prefix> for (IpAddr, u8)
impl From<&Prefix> for (IpAddr, u8)
Source§fn from(prefix: &Prefix) -> (IpAddr, u8)
fn from(prefix: &Prefix) -> (IpAddr, u8)
Convert from IpAddr/CIDR to Prefix
use std::net::{IpAddr, Ipv4Addr};
use bgp_rs::Prefix;
let prefix: Prefix = ("5.5.5.5".parse().unwrap(), 32).into();
let (addr, length) = (&prefix).into();
assert_eq!(addr, IpAddr::from(Ipv4Addr::new(5, 5, 5, 5)));
assert_eq!(length, 32);
impl Eq for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations§
impl Freeze for Prefix
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations§
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
Mutably borrows from an owned value. Read more