rs_internal_hasher 0.1.1

This package serves as an essential building block within the `rs_ssl` cryptographic library. It is focused on providing foundational functionality and infrastructure for various cryptographic operations within the larger project. While this package has been made publicly available to satisfy the dependency requirements of Rust's cargo system, its utility is predominantly realized in the context of the `rs_ssl` project. Unless you are developing or maintaining a component of the `rs_ssl` project, this package might offer limited direct utility. For access to a full suite of cryptographic functionalities, consider using the `rs_ssl` library bundle.
Documentation
use crate::BigEndianBytes;
use core::ops::{Add, AddAssign, BitAnd, Mul, Rem};

#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct U128Size(u128);

impl Add<usize> for U128Size {
    type Output = usize;

    fn add(self, rhs: usize) -> Self::Output {
        (self.0 + rhs as u128) as usize
    }
}

impl AddAssign<usize> for U128Size {
    fn add_assign(&mut self, rhs: usize) {
        self.0 += rhs as u128
    }
}

impl BitAnd for U128Size {
    type Output = usize;

    fn bitand(self, rhs: Self) -> Self::Output {
        (self.0 & rhs.0) as usize
    }
}

impl BigEndianBytes for U128Size {
    type BigEndianBytesArray = [u8; 16];

    fn to_be_bytes(&self) -> Self::BigEndianBytesArray {
        (self.0 * 8).to_be_bytes()
    }
}

impl From<u64> for U128Size {
    fn from(value: u64) -> Self {
        Self(value as u128)
    }
}

impl From<u128> for U128Size {
    fn from(value: u128) -> Self {
        Self(value)
    }
}

impl From<usize> for U128Size {
    fn from(value: usize) -> Self {
        Self(value as u128)
    }
}

impl Mul<u32> for U128Size {
    type Output = Self;

    fn mul(self, rhs: u32) -> Self::Output {
        U128Size::from(self.0 * rhs as u128)
    }
}

impl Rem for U128Size {
    type Output = usize;

    fn rem(self, rhs: Self) -> Self::Output {
        (self.0 % rhs.0) as usize
    }
}