1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[cfg(feature = "core")]
pub mod core;

#[cfg(feature = "std")]
pub mod std;

pub trait TBytes {
    fn size(&self) -> usize;

    fn to_bytes(&self) -> Vec<u8>;

    fn from_bytes(buffer: &mut Vec<u8>) -> Option<Self>
    where
        Self: Sized;

    fn from_bytes_ref(buffer: &[u8]) -> Option<Self>
    where
        Self: Sized,
    {
        let mut buffer = buffer.to_vec();
        buffer.reverse();
        Self::from_bytes(&mut buffer)
    }
}

pub extern crate bytes_kman_derive;
pub use bytes_kman_derive::Bytes;

pub mod prelude {
    pub use super::Bytes;
    pub use super::TBytes;
}