use super::packet::{Ipv6Packet, Ipv6PacketMut};
use crate::error::ParseError;
use crate::ethernet::{
ether_type::EtherType,
frame::{EthernetFrame, EthernetFrameMut},
};
impl<'a> EthernetFrame<'a> {
#[inline]
pub fn ipv6(&self) -> Result<Option<Ipv6Packet<'a>>, ParseError> {
if self.ether_type() != EtherType::IPV6 {
return Ok(None);
}
Ipv6Packet::parse(self.payload()).map(Some)
}
}
impl<'a> EthernetFrameMut<'a> {
#[inline]
pub fn ipv6_mut(&mut self) -> Result<Option<Ipv6PacketMut<'_>>, ParseError> {
if self.ether_type() != EtherType::IPV6 {
return Ok(None);
}
Ipv6PacketMut::parse(self.payload_mut()).map(Some)
}
}