Struct ppp::v2::Header [−][src]
pub struct Header<'a> {
pub header: &'a [u8],
pub version: Version,
pub command: Command,
pub protocol: Protocol,
pub addresses: Addresses,
}
Expand description
A proxy protocol version 2 header.
Examples
use ppp::v2::{Addresses, AddressFamily, Command, Header, IPv4, ParseError, Protocol, PROTOCOL_PREFIX, Type, TypeLengthValue, Version};
let mut header = Vec::from(PROTOCOL_PREFIX);
header.extend([
0x21, 0x12, 0, 16, 127, 0, 0, 1, 192, 168, 1, 1, 0, 80, 1, 187, 4, 0, 1, 42
]);
let addresses: Addresses = IPv4::new([127, 0, 0, 1], [192, 168, 1, 1], 80, 443).into();
let expected = Header {
header: header.as_slice(),
version: Version::Two,
command: Command::Proxy,
protocol: Protocol::Datagram,
addresses
};
let actual = Header::try_from(header.as_slice()).unwrap();
assert_eq!(actual, expected);
assert_eq!(actual.tlvs().collect::<Vec<Result<TypeLengthValue<'_>, ParseError>>>(), vec![Ok(TypeLengthValue::new(Type::NoOp, &[42]))]);
Fields
header: &'a [u8]
version: Version
command: Command
protocol: Protocol
addresses: Addresses
Implementations
The AddressFamily
of this Header
.
The bytes of the address portion of the payload.
The bytes of the TypeLengthValue
portion of the payload.
pub fn tlvs(&self) -> TypeLengthValues<'a>ⓘNotable traits for TypeLengthValues<'a>impl<'a> Iterator for TypeLengthValues<'a> type Item = Result<TypeLengthValue<'a>, ParseError>;
pub fn tlvs(&self) -> TypeLengthValues<'a>ⓘNotable traits for TypeLengthValues<'a>impl<'a> Iterator for TypeLengthValues<'a> type Item = Result<TypeLengthValue<'a>, ParseError>;
Notable traits for TypeLengthValues<'a>
impl<'a> Iterator for TypeLengthValues<'a> type Item = Result<TypeLengthValue<'a>, ParseError>;
An Iterator
of TypeLengthValue
s.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Header<'a>
impl<'a> UnwindSafe for Header<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more