nardol 0.0.3

Simple framework that provides structure to data sent and received from network.
Documentation
use chrono::{DateTime, Utc};

use crate::bytes::Bytes;

impl From<Vec<u8>> for Bytes {
    fn from(value: Vec<u8>) -> Self {
        Bytes(value)
    }
}

impl<const L: usize> From<[u8; L]> for Bytes {
    fn from(value: [u8; L]) -> Self {
        let bytes: Bytes = value.iter().copied().collect();

        bytes
    }
}

impl From<usize> for Bytes {
    fn from(value: usize) -> Self {
        Bytes::from(value.to_be_bytes())
    }
}

impl From<u8> for Bytes {
    fn from(value: u8) -> Self {
        Bytes::from(value.to_be_bytes())
    }
}

impl From<u16> for Bytes {
    fn from(value: u16) -> Self {
        Bytes::from(value.to_be_bytes())
    }
}

impl From<u32> for Bytes {
    fn from(value: u32) -> Self {
        Bytes::from(value.to_be_bytes())
    }
}

impl From<String> for Bytes {
    fn from(value: String) -> Self {
        Bytes::from(value.into_bytes())
    }
}

impl From<DateTime<Utc>> for Bytes {
    fn from(value: DateTime<Utc>) -> Self {
        Bytes::from(value.timestamp() as usize)
    }
}