pub struct Header { /* private fields */ }Expand description
PROXY protocol v1 header.
Implementations§
Source§impl Header
impl Header
Sourcepub fn new(af: AddressFamily, src: SocketAddr, dst: SocketAddr) -> Header
pub fn new(af: AddressFamily, src: SocketAddr, dst: SocketAddr) -> Header
Constructs a new PROXY protocol v1 header.
§Panics
Panics if af is not AddressFamily::Inet or AddressFamily::Inet6, or when the
supplied socket addresses do not match the address family.
Sourcepub fn new_inet(src: SocketAddr, dst: SocketAddr) -> Header
pub fn new_inet(src: SocketAddr, dst: SocketAddr) -> Header
Constructs a new IPv4 PROXY protocol v1 header.
Sourcepub fn new_inet6(src: SocketAddr, dst: SocketAddr) -> Header
pub fn new_inet6(src: SocketAddr, dst: SocketAddr) -> Header
Constructs a new IPv6 PROXY protocol v1 header.
Sourcepub const fn addresses(&self) -> Option<SocketAddresses>
pub const fn addresses(&self) -> Option<SocketAddresses>
Returns socket address metadata when this is not an UNKNOWN header.
Sourcepub fn source_addr(&self) -> Option<SocketAddr>
pub fn source_addr(&self) -> Option<SocketAddr>
Returns the source socket address when available.
Sourcepub fn destination_addr(&self) -> Option<SocketAddr>
pub fn destination_addr(&self) -> Option<SocketAddr>
Returns the destination socket address when available.
Sourcepub fn write_to(&self, wrt: &mut impl Write) -> Result<(), Error>
pub fn write_to(&self, wrt: &mut impl Write) -> Result<(), Error>
Writes this header to an I/O writer.
Sourcepub async fn write_to_tokio(
&self,
wrt: &mut (impl AsyncWrite + Unpin),
) -> Result<(), Error>
pub async fn write_to_tokio( &self, wrt: &mut (impl AsyncWrite + Unpin), ) -> Result<(), Error>
Writes this header to a Tokio async writer.
Sourcepub fn try_from_bytes(
slice: &[u8],
) -> Result<(&[u8], Header), ErrMode<ContextError>>
pub fn try_from_bytes( slice: &[u8], ) -> Result<(&[u8], Header), ErrMode<ContextError>>
Attempts to parse a PROXY protocol v1 header from bytes.
Trait Implementations§
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnsafeUnpin for Header
impl UnwindSafe for Header
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