use serde::{Deserialize, Serialize};
use std::net::Ipv4Addr;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct AddressOption(Ipv4Addr);
impl AddressOption {
pub fn new(ip: Ipv4Addr) -> Self {
Self(ip)
}
#[inline]
pub fn extend_into(&self, bytes: &mut Vec<u8>, tag: u8) {
bytes.push(tag); bytes.push(4); bytes.extend_from_slice(&self.0.octets()); }
pub fn inner(&self) -> Ipv4Addr {
self.0
}
}
impl From<&[u8]> for AddressOption {
fn from(value: &[u8]) -> Self {
Self(Ipv4Addr::new(value[0], value[1], value[2], value[3]))
}
}