/// Create a new BitBuffer from a byte vector
///
/// # Examples
///
/// ```
/// use bitbuffer::{BitReadBuffer, LittleEndian};
///
/// let bytes = vec![
///     0b1011_0101, 0b0110_1010, 0b1010_1100, 0b1001_1001,
///     0b1001_1001, 0b1001_1001, 0b1001_1001, 0b1110_0111
/// ];
/// let buffer = BitReadBuffer::new_owned(bytes, LittleEndian);
/// ```
Create a new BitBuffer from a byte vector
Create a new BitBuffer from a byte vector
pub fn new_owned(bytes: Vec<u8>, _endianness: E) -> Self {
        let byte_len = bytes.len();
        let bytes = Data::Owned(Rc::from(bytes));
        // this is safe because
        //  - the slice can only be access trough this struct
        //  - this struct keeps the vec the slice comes from alive
        //  - this struct doesn't allow mutation
        let slice = unsafe { std::slice::from_raw_parts(bytes.as_slice().as_ptr(), bytes.len()) };
        BitReadBuffer {
            bytes,
            bit_len: byte_len * 8,
            endianness: PhantomData,
            slice,
        }
    }
pub fn new_owned ( bytes : Vec < u8 > , _endianness : E ) -> Self { let byte_len = bytes . len ( ) ; let bytes = Data :: Owned ( Rc :: from ( bytes ) ) ; // this is safe because //  - the slice can only be access trough this struct //  - this struct keeps the vec the slice comes from alive //  - this struct doesn't allow mutation let slice = unsafe { std :: slice :: from_raw_parts ( bytes . as_slice ( ) . as_ptr ( ) , bytes . len ( ) ) } ; BitReadBuffer { bytes , bit_len : byte_len * 8 , endianness : PhantomData , slice , } }
Create a new BitBuffer from a byte vector
Create a new BitBuffer from a byte vector
bytes
Vec<u8>
_endianness
E
examples
```
use bitbuffer::{BitReadBuffer, LittleEndian}.


` ` ` use bitbuffer :: { BitReadBuffer LittleEndian } .