use crate::error::Result;
use crate::net::platform::{Platform, PlatformImpl};
use std::net::IpAddr;
#[derive(Debug, Copy, Clone)]
pub enum Ipv4ByteOrder {
#[cfg(all(unix, not(target_os = "linux"), not(target_os = "windows")))]
Host,
Network,
}
impl Ipv4ByteOrder {
pub fn for_address(addr: IpAddr) -> Result<Self> {
PlatformImpl::byte_order_for_address(addr)
}
#[must_use]
pub const fn adjust_length(self, ipv4_total_length: u16) -> u16 {
match self {
#[cfg(all(unix, not(target_os = "linux"), not(target_os = "windows")))]
Self::Host => ipv4_total_length.swap_bytes(),
Self::Network => ipv4_total_length,
}
}
}