Documentation
/*
==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--

Bi

Copyright (C) 2019, 2021-2022, 2024  Anonymous

There are several releases over multiple years,
they are listed as ranges, such as: "2021-2022".

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--::--
*/

//! # Bytes

use {
    core::{
        ops::Deref,
        sync::atomic::AtomicUsize,
    },
    std::sync::Arc,
    crate::Counter,
};

mod tests;

/// # Bytes
///
/// This is a simple wrapper for `Vec<u8>`.
///
/// For examples, see [`Bi`][struct:Bi].
///
/// [struct:Bi]: struct.Bi.html
#[derive(Debug)]
pub struct Bytes {
    bytes: Vec<u8>,
    _counter: Counter,
}

impl Bytes {

    /// # Makes new instance
    pub (crate) fn new(bytes: Vec<u8>, counter: Arc<AtomicUsize>) -> Self {
        let _counter = Counter::new(bytes.len(), counter);
        Self {
            bytes,
            _counter,
        }
    }

}

impl Deref for Bytes {

    type Target = [u8];

    fn deref(&self) -> &Self::Target {
        &self.bytes
    }

}

impl From<Bytes> for Vec<u8> {

    fn from(bytes: Bytes) -> Self {
        bytes.bytes
    }

}