Closes: #158 Approved by: whitequark
@@ -242,6 +242,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
}
+impl<T: AsRef<[u8]>> AsRef<[u8]> for Packet<T> {
+ fn as_ref(&self) -> &[u8] {
+ self.buffer.as_ref()
+ }
+}
+
use super::{EthernetAddress, Ipv4Address};
/// A high-level representation of an Address Resolution Protocol packet.
@@ -196,6 +196,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Frame<T> {
+impl<T: AsRef<[u8]>> AsRef<[u8]> for Frame<T> {
impl<T: AsRef<[u8]>> fmt::Display for Frame<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "EthernetII src={} dst={} type={}",
@@ -358,6 +358,12 @@ impl<'a, T: AsRef<[u8]> + AsMut<[u8]> + ?Sized> Packet<&'a mut T> {
/// A high-level representation of an Internet Control Message Protocol version 4 packet header.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Repr<'a> {
@@ -367,6 +367,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
/// A high-level representation of an Internet Control Message Protocol version 6 packet header.
@@ -534,6 +534,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
/// A high-level representation of an Internet Protocol version 4 packet header.
pub struct Repr {
@@ -560,6 +560,12 @@ impl<'a, T: AsRef<[u8]> + ?Sized> fmt::Display for Packet<&'a T> {
/// A high-level representation of an Internet Protocol version 6 packet header.
@@ -510,6 +510,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
/// A representation of a single TCP option.
pub enum TcpOption<'a> {
@@ -190,6 +190,12 @@ impl<T: AsRef<[u8]> + AsMut<[u8]>> Packet<T> {
/// A high-level representation of an User Datagram Protocol packet.
pub struct Repr<'a> {