use std::convert::From;
use std::fmt;
use std::ops;
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C, packed)]
pub struct u16be(pub u16);
impl u16be {
pub const MIN: u16be = u16be(0);
}
impl From<u16> for u16be {
fn from(item: u16) -> Self {
u16be(u16::to_be(item))
}
}
impl From<u16be> for u16 {
fn from(item: u16be) -> Self {
u16::from_be(item.0)
}
}
impl ops::BitAnd for u16be {
type Output = Self;
fn bitand(self, rhs: Self) -> Self::Output {
u16be(self.0 & rhs.0)
}
}
impl ops::BitAndAssign for u16be {
fn bitand_assign(&mut self, rhs: Self) {
*self = Self(self.0 & rhs.0)
}
}
impl ops::BitOr for u16be {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ops::BitOrAssign for u16be {
fn bitor_assign(&mut self, rhs: Self) {
*self = Self(self.0 | rhs.0)
}
}
impl ops::BitXor for u16be {
type Output = Self;
fn bitxor(self, rhs: Self) -> Self {
Self(self.0 ^ rhs.0)
}
}
impl ops::BitXorAssign for u16be {
fn bitxor_assign(&mut self, rhs: Self) {
*self = Self(self.0 ^ rhs.0)
}
}
impl ops::Not for u16be {
type Output = Self;
fn not(self) -> Self::Output {
u16be(!self.0)
}
}
impl fmt::Display for u16be {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let item = self.0;
item.fmt(f)
}
}
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C, packed)]
pub struct u32be(pub u32);
impl u32be {
pub const MIN: u32be = u32be(0);
}
impl From<u32> for u32be {
fn from(item: u32) -> Self {
u32be(u32::to_be(item))
}
}
impl From<u32be> for u32 {
fn from(item: u32be) -> Self {
u32::from_be(item.0)
}
}
impl ops::BitAnd for u32be {
type Output = Self;
fn bitand(self, rhs: Self) -> Self::Output {
u32be(self.0 & rhs.0)
}
}
impl ops::BitAndAssign for u32be {
fn bitand_assign(&mut self, rhs: Self) {
*self = Self(self.0 & rhs.0)
}
}
impl ops::BitOr for u32be {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ops::BitOrAssign for u32be {
fn bitor_assign(&mut self, rhs: Self) {
*self = Self(self.0 | rhs.0)
}
}
impl ops::BitXor for u32be {
type Output = Self;
fn bitxor(self, rhs: Self) -> Self {
Self(self.0 ^ rhs.0)
}
}
impl ops::BitXorAssign for u32be {
fn bitxor_assign(&mut self, rhs: Self) {
*self = Self(self.0 ^ rhs.0)
}
}
impl ops::Not for u32be {
type Output = Self;
fn not(self) -> Self::Output {
u32be(!self.0)
}
}
impl fmt::Display for u32be {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let item = self.0;
item.fmt(f)
}
}