[][src]Struct tox_packet::ip_port::IpPort

pub struct IpPort {
    pub protocol: ProtocolType,
    pub ip_addr: IpAddr,
    pub port: u16,
}

IpAddr with a port number. IPv4 can be padded with 12 bytes of zeros so that both IPv4 and IPv6 have the same stored size.

Serialized form:

LengthContent
1IpType
4 or 16IPv4 or IPv6 address
0 or 12Padding for IPv4 (if needed)
2Port

Fields

protocol: ProtocolType

Type of protocol

ip_addr: IpAddr

IP address

port: u16

Port number

Implementations

impl IpPort[src]

pub fn from_udp_bytes(
    input: &[u8],
    padding: IpPortPadding
) -> IResult<&[u8], IpPort>
[src]

Parse IpPort with UDP protocol type with optional padding.

pub fn from_tcp_bytes(
    input: &[u8],
    padding: IpPortPadding
) -> IResult<&[u8], IpPort>
[src]

Parse IpPort with TCP protocol type with optional padding.

pub fn from_bytes(
    input: &[u8],
    padding: IpPortPadding
) -> IResult<&[u8], IpPort>
[src]

Parse IpPort with optional padding.

pub fn to_udp_bytes<'a>(
    &self,
    buf: (&'a mut [u8], usize),
    padding: IpPortPadding
) -> Result<(&'a mut [u8], usize), GenError>
[src]

Write IpPort with UDP protocol type with optional padding.

pub fn to_tcp_bytes<'a>(
    &self,
    buf: (&'a mut [u8], usize),
    padding: IpPortPadding
) -> Result<(&'a mut [u8], usize), GenError>
[src]

Write IpPort with TCP protocol type with optional padding.

pub fn to_bytes<'a>(
    &self,
    buf: (&'a mut [u8], usize),
    padding: IpPortPadding
) -> Result<(&'a mut [u8], usize), GenError>
[src]

Write IpPort with optional padding.

pub fn from_udp_saddr(saddr: SocketAddr) -> IpPort[src]

Create new IpPort from SocketAddr with UDP type.

pub fn from_tcp_saddr(saddr: SocketAddr) -> IpPort[src]

Create new IpPort from SocketAddr with TCP type.

pub fn to_saddr(&self) -> SocketAddr[src]

Convert IpPort to SocketAddr.

Trait Implementations

impl Clone for IpPort[src]

impl Debug for IpPort[src]

impl Eq for IpPort[src]

impl PartialEq<IpPort> for IpPort[src]

impl StructuralEq for IpPort[src]

impl StructuralPartialEq for IpPort[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.