pub struct BitBuf<S> { /* private fields */ }Expand description
The main structure
Keeps track of the data storage and a cursor for automatic operations
Implementations§
Source§impl<S> BitBuf<S>
impl<S> BitBuf<S>
Sourcepub fn bytes_mut(&mut self) -> &mut [u8]where
S: StorageMut,
pub fn bytes_mut(&mut self) -> &mut [u8]where
S: StorageMut,
Get the underlying bytes from the storage
Sourcepub fn pos(&self) -> usize
pub fn pos(&self) -> usize
Get the internal cursor for automatic operations
The cursor may not be within storage bounds
Sourcepub fn byte_pos(&self) -> usize
pub fn byte_pos(&self) -> usize
Get the byte-aligned position of the internal cursor for automatic operations
The cursor may not be within storage bounds
Sourcepub fn advance(&mut self, bits: usize) -> &mut Self
pub fn advance(&mut self, bits: usize) -> &mut Self
Advance the internal cursor for automatic operations
This does not enforce that the cursor stay within storage bounds
Sourcepub fn advance_bytes(&mut self, bytes: usize) -> &mut Self
pub fn advance_bytes(&mut self, bytes: usize) -> &mut Self
Advance the internal cursor for automatic operations by a number of bytes
This does not enforce that the cursor stay within storage bounds
Sourcepub fn seek(&mut self, offset: usize) -> &mut Self
pub fn seek(&mut self, offset: usize) -> &mut Self
Set the internal cursor for automatic operations
This does not enforce that the cursor stay within storage bounds
Sourcepub fn seek_byte(&mut self, byte: usize) -> &mut Self
pub fn seek_byte(&mut self, byte: usize) -> &mut Self
Set the internal cursor for automatic operations to a byte position
This sets the cursor to offset * 8 bits.
This does not enforce that the cursor stay within storage bounds
Sourcepub fn is_aligned(&self) -> bool
pub fn is_aligned(&self) -> bool
Checks if the internal cursor for automatic operations is aligned on the start of a byte
This does not care whether the cursor is outside storage bounds
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u8_be_aligned_at_unchecked(&self, byte_offset: usize) -> u8
pub unsafe fn read_u8_be_aligned_at_unchecked(&self, byte_offset: usize) -> u8
Read a u8 in [BE-bit, BE-byte] order from byte_offset, without performing bound checks
§Safety
- This is UB if
byte_offset + 0 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 0 >= self.bytes().len()
Sourcepub unsafe fn read_u8_be_aligned_unchecked(&mut self) -> u8
pub unsafe fn read_u8_be_aligned_unchecked(&mut self) -> u8
Read the next u8 in [BE-bit, BE-byte] order, without validating cursor alignment or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 0 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 0 >= self.bytes().len()
Sourcepub unsafe fn read_u8_be_at_unchecked(&self, offset: usize) -> u8
pub unsafe fn read_u8_be_at_unchecked(&self, offset: usize) -> u8
Read a u8 in [BE-bit, BE-byte] order from offset, without performing bound checks
§Safety
- This is UB if
(offset / 8) + 0 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 0 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
Sourcepub unsafe fn read_u8_be_unchecked(&mut self) -> u8
pub unsafe fn read_u8_be_unchecked(&mut self) -> u8
Read the next u8 in [BE-bit, BE-byte] order, without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 0 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 0 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
Sourcepub fn try_read_u8_be_aligned_at(&self, byte_offset: usize) -> Result<u8>
pub fn try_read_u8_be_aligned_at(&self, byte_offset: usize) -> Result<u8>
Read a u8 in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 0 >= self.bytes().len()
- if
Sourcepub fn try_read_u8_be_aligned(&mut self) -> Result<u8>
pub fn try_read_u8_be_aligned(&mut self) -> Result<u8>
Read the next u8 in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 0 >= self.bytes().len()
- if
Sourcepub fn try_read_u8_be_at(&self, offset: usize) -> Result<u8>
pub fn try_read_u8_be_at(&self, offset: usize) -> Result<u8>
Read a u8 in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 0 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
- if
Sourcepub fn try_read_u8_be(&mut self) -> Result<u8>
pub fn try_read_u8_be(&mut self) -> Result<u8>
Read the next u8 in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 0 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
- if
Sourcepub fn read_u8_be_aligned_at(&self, byte_offset: usize) -> u8
pub fn read_u8_be_aligned_at(&self, byte_offset: usize) -> u8
Read a u8 in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
- Panics if
byte_offset + 0 >= self.bytes().len()
Sourcepub fn read_u8_be_aligned(&mut self) -> u8
pub fn read_u8_be_aligned(&mut self) -> u8
Read the next u8 in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 0 >= self.bytes().len()
Sourcepub fn read_u8_be_at(&self, offset: usize) -> u8
pub fn read_u8_be_at(&self, offset: usize) -> u8
Read a u8 in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 0 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
Sourcepub fn read_u8_be(&mut self) -> u8
pub fn read_u8_be(&mut self) -> u8
Read the next u8 in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
- Panics if
(self.pos() / 8) + 0 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u8_be_aligned_bits_at_unchecked(
&self,
byte_offset: usize,
bits: usize,
) -> u8
pub unsafe fn read_u8_be_aligned_bits_at_unchecked( &self, byte_offset: usize, bits: usize, ) -> u8
Read a u8 in [BE-bit, BE-byte] order using bits bits from byte_offset, without validating the bit count or performing bound checks
§Safety
- This is UB
- if
bits > 8 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if
bits > 8 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub unsafe fn read_u8_be_aligned_bits_unchecked(&mut self, bits: usize) -> u8
pub unsafe fn read_u8_be_aligned_bits_unchecked(&mut self, bits: usize) -> u8
Read the next u8 in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB
- if
bits > 8 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 8 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if the internal cursor is not byte-aligned (
Sourcepub fn try_read_u8_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> Result<u8>
pub fn try_read_u8_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> Result<u8>
Read a u8 in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
- Returns
Error::InvalidBitCount- if
bits > 8
- if
- Returns
Error::OutOfBounds- if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn try_read_u8_be_aligned_bits(&mut self, bits: usize) -> Result<u8>
pub fn try_read_u8_be_aligned_bits(&mut self, bits: usize) -> Result<u8>
Read the next u8 in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::InvalidBitCount- if
bits > 8
- if
- Returns
Error::OutOfBounds- if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn read_u8_be_aligned_bits_at(&self, byte_offset: usize, bits: usize) -> u8
pub fn read_u8_be_aligned_bits_at(&self, byte_offset: usize, bits: usize) -> u8
Read a u8 in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
- if
bits > 8 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
Sourcepub fn read_u8_be_aligned_bits(&mut self, bits: usize) -> u8
pub fn read_u8_be_aligned_bits(&mut self, bits: usize) -> u8
Read the next u8 in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 8 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u16_be_aligned_at_unchecked(&self, byte_offset: usize) -> u16
pub unsafe fn read_u16_be_aligned_at_unchecked(&self, byte_offset: usize) -> u16
Read a u16 in [BE-bit, BE-byte] order from byte_offset, without performing bound checks
§Safety
- This is UB if
byte_offset + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 1 >= self.bytes().len()
Sourcepub unsafe fn read_u16_be_aligned_unchecked(&mut self) -> u16
pub unsafe fn read_u16_be_aligned_unchecked(&mut self) -> u16
Read the next u16 in [BE-bit, BE-byte] order, without validating cursor alignment or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 1 >= self.bytes().len()
Sourcepub unsafe fn read_u16_be_at_unchecked(&self, offset: usize) -> u16
pub unsafe fn read_u16_be_at_unchecked(&self, offset: usize) -> u16
Read a u16 in [BE-bit, BE-byte] order from offset, without performing bound checks
§Safety
- This is UB if
(offset / 8) + 1 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 1 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
Sourcepub unsafe fn read_u16_be_unchecked(&mut self) -> u16
pub unsafe fn read_u16_be_unchecked(&mut self) -> u16
Read the next u16 in [BE-bit, BE-byte] order, without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 1 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 1 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
Sourcepub fn try_read_u16_be_aligned_at(&self, byte_offset: usize) -> Result<u16>
pub fn try_read_u16_be_aligned_at(&self, byte_offset: usize) -> Result<u16>
Read a u16 in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 1 >= self.bytes().len()
- if
Sourcepub fn try_read_u16_be_aligned(&mut self) -> Result<u16>
pub fn try_read_u16_be_aligned(&mut self) -> Result<u16>
Read the next u16 in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 1 >= self.bytes().len()
- if
Sourcepub fn try_read_u16_be_at(&self, offset: usize) -> Result<u16>
pub fn try_read_u16_be_at(&self, offset: usize) -> Result<u16>
Read a u16 in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 1 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
- if
Sourcepub fn try_read_u16_be(&mut self) -> Result<u16>
pub fn try_read_u16_be(&mut self) -> Result<u16>
Read the next u16 in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 1 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
- if
Sourcepub fn read_u16_be_aligned_at(&self, byte_offset: usize) -> u16
pub fn read_u16_be_aligned_at(&self, byte_offset: usize) -> u16
Read a u16 in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
- Panics if
byte_offset + 1 >= self.bytes().len()
Sourcepub fn read_u16_be_aligned(&mut self) -> u16
pub fn read_u16_be_aligned(&mut self) -> u16
Read the next u16 in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 1 >= self.bytes().len()
Sourcepub fn read_u16_be_at(&self, offset: usize) -> u16
pub fn read_u16_be_at(&self, offset: usize) -> u16
Read a u16 in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 1 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
Sourcepub fn read_u16_be(&mut self) -> u16
pub fn read_u16_be(&mut self) -> u16
Read the next u16 in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
- Panics if
(self.pos() / 8) + 1 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u16_be_aligned_bits_at_unchecked(
&self,
byte_offset: usize,
bits: usize,
) -> u16
pub unsafe fn read_u16_be_aligned_bits_at_unchecked( &self, byte_offset: usize, bits: usize, ) -> u16
Read a u16 in [BE-bit, BE-byte] order using bits bits from byte_offset, without validating the bit count or performing bound checks
§Safety
- This is UB
- if
bits > 16 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if
bits > 16 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub unsafe fn read_u16_be_aligned_bits_unchecked(&mut self, bits: usize) -> u16
pub unsafe fn read_u16_be_aligned_bits_unchecked(&mut self, bits: usize) -> u16
Read the next u16 in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB
- if
bits > 16 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 16 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if the internal cursor is not byte-aligned (
Sourcepub fn try_read_u16_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> Result<u16>
pub fn try_read_u16_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> Result<u16>
Read a u16 in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
- Returns
Error::InvalidBitCount- if
bits > 16
- if
- Returns
Error::OutOfBounds- if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn try_read_u16_be_aligned_bits(&mut self, bits: usize) -> Result<u16>
pub fn try_read_u16_be_aligned_bits(&mut self, bits: usize) -> Result<u16>
Read the next u16 in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::InvalidBitCount- if
bits > 16
- if
- Returns
Error::OutOfBounds- if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn read_u16_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> u16
pub fn read_u16_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> u16
Read a u16 in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
- if
bits > 16 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
Sourcepub fn read_u16_be_aligned_bits(&mut self, bits: usize) -> u16
pub fn read_u16_be_aligned_bits(&mut self, bits: usize) -> u16
Read the next u16 in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 16 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u32_be_aligned_at_unchecked(&self, byte_offset: usize) -> u32
pub unsafe fn read_u32_be_aligned_at_unchecked(&self, byte_offset: usize) -> u32
Read a u32 in [BE-bit, BE-byte] order from byte_offset, without performing bound checks
§Safety
- This is UB if
byte_offset + 3 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 3 >= self.bytes().len()
Sourcepub unsafe fn read_u32_be_aligned_unchecked(&mut self) -> u32
pub unsafe fn read_u32_be_aligned_unchecked(&mut self) -> u32
Read the next u32 in [BE-bit, BE-byte] order, without validating cursor alignment or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 3 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 3 >= self.bytes().len()
Sourcepub unsafe fn read_u32_be_at_unchecked(&self, offset: usize) -> u32
pub unsafe fn read_u32_be_at_unchecked(&self, offset: usize) -> u32
Read a u32 in [BE-bit, BE-byte] order from offset, without performing bound checks
§Safety
- This is UB if
(offset / 8) + 3 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 3 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
Sourcepub unsafe fn read_u32_be_unchecked(&mut self) -> u32
pub unsafe fn read_u32_be_unchecked(&mut self) -> u32
Read the next u32 in [BE-bit, BE-byte] order, without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 3 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 3 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
Sourcepub fn try_read_u32_be_aligned_at(&self, byte_offset: usize) -> Result<u32>
pub fn try_read_u32_be_aligned_at(&self, byte_offset: usize) -> Result<u32>
Read a u32 in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 3 >= self.bytes().len()
- if
Sourcepub fn try_read_u32_be_aligned(&mut self) -> Result<u32>
pub fn try_read_u32_be_aligned(&mut self) -> Result<u32>
Read the next u32 in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 3 >= self.bytes().len()
- if
Sourcepub fn try_read_u32_be_at(&self, offset: usize) -> Result<u32>
pub fn try_read_u32_be_at(&self, offset: usize) -> Result<u32>
Read a u32 in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 3 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
- if
Sourcepub fn try_read_u32_be(&mut self) -> Result<u32>
pub fn try_read_u32_be(&mut self) -> Result<u32>
Read the next u32 in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 3 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
- if
Sourcepub fn read_u32_be_aligned_at(&self, byte_offset: usize) -> u32
pub fn read_u32_be_aligned_at(&self, byte_offset: usize) -> u32
Read a u32 in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
- Panics if
byte_offset + 3 >= self.bytes().len()
Sourcepub fn read_u32_be_aligned(&mut self) -> u32
pub fn read_u32_be_aligned(&mut self) -> u32
Read the next u32 in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 3 >= self.bytes().len()
Sourcepub fn read_u32_be_at(&self, offset: usize) -> u32
pub fn read_u32_be_at(&self, offset: usize) -> u32
Read a u32 in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 3 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
Sourcepub fn read_u32_be(&mut self) -> u32
pub fn read_u32_be(&mut self) -> u32
Read the next u32 in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
- Panics if
(self.pos() / 8) + 3 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u32_be_aligned_bits_at_unchecked(
&self,
byte_offset: usize,
bits: usize,
) -> u32
pub unsafe fn read_u32_be_aligned_bits_at_unchecked( &self, byte_offset: usize, bits: usize, ) -> u32
Read a u32 in [BE-bit, BE-byte] order using bits bits from byte_offset, without validating the bit count or performing bound checks
§Safety
- This is UB
- if
bits > 32 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if
bits > 32 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub unsafe fn read_u32_be_aligned_bits_unchecked(&mut self, bits: usize) -> u32
pub unsafe fn read_u32_be_aligned_bits_unchecked(&mut self, bits: usize) -> u32
Read the next u32 in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB
- if
bits > 32 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 32 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if the internal cursor is not byte-aligned (
Sourcepub fn try_read_u32_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> Result<u32>
pub fn try_read_u32_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> Result<u32>
Read a u32 in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
- Returns
Error::InvalidBitCount- if
bits > 32
- if
- Returns
Error::OutOfBounds- if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn try_read_u32_be_aligned_bits(&mut self, bits: usize) -> Result<u32>
pub fn try_read_u32_be_aligned_bits(&mut self, bits: usize) -> Result<u32>
Read the next u32 in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::InvalidBitCount- if
bits > 32
- if
- Returns
Error::OutOfBounds- if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn read_u32_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> u32
pub fn read_u32_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> u32
Read a u32 in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
- if
bits > 32 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
Sourcepub fn read_u32_be_aligned_bits(&mut self, bits: usize) -> u32
pub fn read_u32_be_aligned_bits(&mut self, bits: usize) -> u32
Read the next u32 in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 32 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u64_be_aligned_at_unchecked(&self, byte_offset: usize) -> u64
pub unsafe fn read_u64_be_aligned_at_unchecked(&self, byte_offset: usize) -> u64
Read a u64 in [BE-bit, BE-byte] order from byte_offset, without performing bound checks
§Safety
- This is UB if
byte_offset + 7 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 7 >= self.bytes().len()
Sourcepub unsafe fn read_u64_be_aligned_unchecked(&mut self) -> u64
pub unsafe fn read_u64_be_aligned_unchecked(&mut self) -> u64
Read the next u64 in [BE-bit, BE-byte] order, without validating cursor alignment or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 7 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 7 >= self.bytes().len()
Sourcepub unsafe fn read_u64_be_at_unchecked(&self, offset: usize) -> u64
pub unsafe fn read_u64_be_at_unchecked(&self, offset: usize) -> u64
Read a u64 in [BE-bit, BE-byte] order from offset, without performing bound checks
§Safety
- This is UB if
(offset / 8) + 7 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 7 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
Sourcepub unsafe fn read_u64_be_unchecked(&mut self) -> u64
pub unsafe fn read_u64_be_unchecked(&mut self) -> u64
Read the next u64 in [BE-bit, BE-byte] order, without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 7 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 7 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
Sourcepub fn try_read_u64_be_aligned_at(&self, byte_offset: usize) -> Result<u64>
pub fn try_read_u64_be_aligned_at(&self, byte_offset: usize) -> Result<u64>
Read a u64 in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 7 >= self.bytes().len()
- if
Sourcepub fn try_read_u64_be_aligned(&mut self) -> Result<u64>
pub fn try_read_u64_be_aligned(&mut self) -> Result<u64>
Read the next u64 in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 7 >= self.bytes().len()
- if
Sourcepub fn try_read_u64_be_at(&self, offset: usize) -> Result<u64>
pub fn try_read_u64_be_at(&self, offset: usize) -> Result<u64>
Read a u64 in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 7 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
- if
Sourcepub fn try_read_u64_be(&mut self) -> Result<u64>
pub fn try_read_u64_be(&mut self) -> Result<u64>
Read the next u64 in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 7 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
- if
Sourcepub fn read_u64_be_aligned_at(&self, byte_offset: usize) -> u64
pub fn read_u64_be_aligned_at(&self, byte_offset: usize) -> u64
Read a u64 in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
- Panics if
byte_offset + 7 >= self.bytes().len()
Sourcepub fn read_u64_be_aligned(&mut self) -> u64
pub fn read_u64_be_aligned(&mut self) -> u64
Read the next u64 in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 7 >= self.bytes().len()
Sourcepub fn read_u64_be_at(&self, offset: usize) -> u64
pub fn read_u64_be_at(&self, offset: usize) -> u64
Read a u64 in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 7 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
Sourcepub fn read_u64_be(&mut self) -> u64
pub fn read_u64_be(&mut self) -> u64
Read the next u64 in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
- Panics if
(self.pos() / 8) + 7 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u64_be_aligned_bits_at_unchecked(
&self,
byte_offset: usize,
bits: usize,
) -> u64
pub unsafe fn read_u64_be_aligned_bits_at_unchecked( &self, byte_offset: usize, bits: usize, ) -> u64
Read a u64 in [BE-bit, BE-byte] order using bits bits from byte_offset, without validating the bit count or performing bound checks
§Safety
- This is UB
- if
bits > 64 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if
bits > 64 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub unsafe fn read_u64_be_aligned_bits_unchecked(&mut self, bits: usize) -> u64
pub unsafe fn read_u64_be_aligned_bits_unchecked(&mut self, bits: usize) -> u64
Read the next u64 in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB
- if
bits > 64 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 64 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if the internal cursor is not byte-aligned (
Sourcepub fn try_read_u64_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> Result<u64>
pub fn try_read_u64_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> Result<u64>
Read a u64 in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
- Returns
Error::InvalidBitCount- if
bits > 64
- if
- Returns
Error::OutOfBounds- if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn try_read_u64_be_aligned_bits(&mut self, bits: usize) -> Result<u64>
pub fn try_read_u64_be_aligned_bits(&mut self, bits: usize) -> Result<u64>
Read the next u64 in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::InvalidBitCount- if
bits > 64
- if
- Returns
Error::OutOfBounds- if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn read_u64_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> u64
pub fn read_u64_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> u64
Read a u64 in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
- if
bits > 64 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
Sourcepub fn read_u64_be_aligned_bits(&mut self, bits: usize) -> u64
pub fn read_u64_be_aligned_bits(&mut self, bits: usize) -> u64
Read the next u64 in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 64 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u128_be_aligned_at_unchecked(
&self,
byte_offset: usize,
) -> u128
pub unsafe fn read_u128_be_aligned_at_unchecked( &self, byte_offset: usize, ) -> u128
Read a u128 in [BE-bit, BE-byte] order from byte_offset, without performing bound checks
§Safety
- This is UB if
byte_offset + 15 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 15 >= self.bytes().len()
Sourcepub unsafe fn read_u128_be_aligned_unchecked(&mut self) -> u128
pub unsafe fn read_u128_be_aligned_unchecked(&mut self) -> u128
Read the next u128 in [BE-bit, BE-byte] order, without validating cursor alignment or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 15 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 15 >= self.bytes().len()
Sourcepub unsafe fn read_u128_be_at_unchecked(&self, offset: usize) -> u128
pub unsafe fn read_u128_be_at_unchecked(&self, offset: usize) -> u128
Read a u128 in [BE-bit, BE-byte] order from offset, without performing bound checks
§Safety
- This is UB if
(offset / 8) + 15 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 15 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
Sourcepub unsafe fn read_u128_be_unchecked(&mut self) -> u128
pub unsafe fn read_u128_be_unchecked(&mut self) -> u128
Read the next u128 in [BE-bit, BE-byte] order, without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 15 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 15 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
Sourcepub fn try_read_u128_be_aligned_at(&self, byte_offset: usize) -> Result<u128>
pub fn try_read_u128_be_aligned_at(&self, byte_offset: usize) -> Result<u128>
Read a u128 in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 15 >= self.bytes().len()
- if
Sourcepub fn try_read_u128_be_aligned(&mut self) -> Result<u128>
pub fn try_read_u128_be_aligned(&mut self) -> Result<u128>
Read the next u128 in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 15 >= self.bytes().len()
- if
Sourcepub fn try_read_u128_be_at(&self, offset: usize) -> Result<u128>
pub fn try_read_u128_be_at(&self, offset: usize) -> Result<u128>
Read a u128 in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 15 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
- if
Sourcepub fn try_read_u128_be(&mut self) -> Result<u128>
pub fn try_read_u128_be(&mut self) -> Result<u128>
Read the next u128 in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 15 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
- if
Sourcepub fn read_u128_be_aligned_at(&self, byte_offset: usize) -> u128
pub fn read_u128_be_aligned_at(&self, byte_offset: usize) -> u128
Read a u128 in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
- Panics if
byte_offset + 15 >= self.bytes().len()
Sourcepub fn read_u128_be_aligned(&mut self) -> u128
pub fn read_u128_be_aligned(&mut self) -> u128
Read the next u128 in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 15 >= self.bytes().len()
Sourcepub fn read_u128_be_at(&self, offset: usize) -> u128
pub fn read_u128_be_at(&self, offset: usize) -> u128
Read a u128 in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 15 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
Sourcepub fn read_u128_be(&mut self) -> u128
pub fn read_u128_be(&mut self) -> u128
Read the next u128 in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
- Panics if
(self.pos() / 8) + 15 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_u128_be_aligned_bits_at_unchecked(
&self,
byte_offset: usize,
bits: usize,
) -> u128
pub unsafe fn read_u128_be_aligned_bits_at_unchecked( &self, byte_offset: usize, bits: usize, ) -> u128
Read a u128 in [BE-bit, BE-byte] order using bits bits from byte_offset, without validating the bit count or performing bound checks
§Safety
- This is UB
- if
bits > 128 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if
bits > 128 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub unsafe fn read_u128_be_aligned_bits_unchecked(
&mut self,
bits: usize,
) -> u128
pub unsafe fn read_u128_be_aligned_bits_unchecked( &mut self, bits: usize, ) -> u128
Read the next u128 in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB
- if
bits > 128 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
§Panics
- Panics in debug mode
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 128 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if the internal cursor is not byte-aligned (
Sourcepub fn try_read_u128_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> Result<u128>
pub fn try_read_u128_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> Result<u128>
Read a u128 in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
- Returns
Error::InvalidBitCount- if
bits > 128
- if
- Returns
Error::OutOfBounds- if
byte_offset + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn try_read_u128_be_aligned_bits(&mut self, bits: usize) -> Result<u128>
pub fn try_read_u128_be_aligned_bits(&mut self, bits: usize) -> Result<u128>
Read the next u128 in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::InvalidBitCount- if
bits > 128
- if
- Returns
Error::OutOfBounds- if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
- if
Sourcepub fn read_u128_be_aligned_bits_at(
&self,
byte_offset: usize,
bits: usize,
) -> u128
pub fn read_u128_be_aligned_bits_at( &self, byte_offset: usize, bits: usize, ) -> u128
Read a u128 in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
- if
bits > 128 - if
byte_offset + bits.div_ceil(8) > self.bytes().len()
Sourcepub fn read_u128_be_aligned_bits(&mut self, bits: usize) -> u128
pub fn read_u128_be_aligned_bits(&mut self, bits: usize) -> u128
Read the next u128 in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
bits > 128 - if
self.byte_pos() + bits.div_ceil(8) > self.bytes().len()
Source§impl<S: Storage> BitBuf<S>
impl<S: Storage> BitBuf<S>
Sourcepub unsafe fn read_be_aligned_at_unchecked<T: Read>(
&self,
byte_offset: usize,
) -> T
pub unsafe fn read_be_aligned_at_unchecked<T: Read>( &self, byte_offset: usize, ) -> T
Sourcepub unsafe fn read_be_aligned_unchecked<T: Read>(&mut self) -> T
pub unsafe fn read_be_aligned_unchecked<T: Read>(&mut self) -> T
Sourcepub unsafe fn read_be_at_unchecked<T: Read>(&self, offset: usize) -> T
pub unsafe fn read_be_at_unchecked<T: Read>(&self, offset: usize) -> T
Sourcepub unsafe fn read_be_unchecked<T: Read>(&mut self) -> T
pub unsafe fn read_be_unchecked<T: Read>(&mut self) -> T
Sourcepub fn try_read_be_aligned_at<T: Read>(&self, byte_offset: usize) -> Result<T>
pub fn try_read_be_aligned_at<T: Read>(&self, byte_offset: usize) -> Result<T>
Read a T in [BE-bit, BE-byte] order from byte_offset, performing bound checks
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_read_be_aligned<T: Read>(&mut self) -> Result<T>
pub fn try_read_be_aligned<T: Read>(&mut self) -> Result<T>
Read the next T in [BE-bit, BE-byte] order, validating cursor alignment and performing bound checks, advancing the internal cursor
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_read_be_at<T: Read>(&self, offset: usize) -> Result<T>
pub fn try_read_be_at<T: Read>(&self, offset: usize) -> Result<T>
Read a T in [BE-bit, BE-byte] order from offset, performing bound checks
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_read_be<T: Read>(&mut self) -> Result<T>
pub fn try_read_be<T: Read>(&mut self) -> Result<T>
Read the next T in [BE-bit, BE-byte] order, performing bound checks, advancing the internal cursor
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn read_be_aligned_at<T: Read>(&self, byte_offset: usize) -> T
pub fn read_be_aligned_at<T: Read>(&self, byte_offset: usize) -> T
Read a T in [BE-bit, BE-byte] order from byte_offset, panicking on out of bounds
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn read_be_aligned<T: Read>(&mut self) -> T
pub fn read_be_aligned<T: Read>(&mut self) -> T
Read the next T in [BE-bit, BE-byte] order, panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn read_be_at<T: Read>(&self, offset: usize) -> T
pub fn read_be_at<T: Read>(&self, offset: usize) -> T
Read a T in [BE-bit, BE-byte] order from offset, panicking on out of bounds
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn read_be<T: Read>(&mut self) -> T
pub fn read_be<T: Read>(&mut self) -> T
Read the next T in [BE-bit, BE-byte] order, panicking on out of bounds, advancing the internal cursor
§Panics
All semantics of the corresponding function for the type apply
Sourcepub unsafe fn read_be_aligned_bits_at_unchecked<T: Read>(
&self,
byte_offset: usize,
bits: usize,
) -> T
pub unsafe fn read_be_aligned_bits_at_unchecked<T: Read>( &self, byte_offset: usize, bits: usize, ) -> T
Sourcepub unsafe fn read_be_aligned_bits_unchecked<T: Read>(
&mut self,
bits: usize,
) -> T
pub unsafe fn read_be_aligned_bits_unchecked<T: Read>( &mut self, bits: usize, ) -> T
Read the next T in [BE-bit, BE-byte] order using bits bits, without validating cursor alignment, the bit count, or performing bound checks, advancing the internal cursor
§Safety
All semantics of the corresponding function for the type apply
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn try_read_be_aligned_bits_at<T: Read>(
&self,
byte_offset: usize,
bits: usize,
) -> Result<T>
pub fn try_read_be_aligned_bits_at<T: Read>( &self, byte_offset: usize, bits: usize, ) -> Result<T>
Read a T in [BE-bit, BE-byte] order using bits bits from byte_offset, validating the bit count and performing bound checks
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_read_be_aligned_bits<T: Read>(&mut self, bits: usize) -> Result<T>
pub fn try_read_be_aligned_bits<T: Read>(&mut self, bits: usize) -> Result<T>
Read the next T in [BE-bit, BE-byte] order using bits bits, validating cursor alignment, the bit count, and performing bound checks, advancing the internal cursor
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn read_be_aligned_bits_at<T: Read>(
&self,
byte_offset: usize,
bits: usize,
) -> T
pub fn read_be_aligned_bits_at<T: Read>( &self, byte_offset: usize, bits: usize, ) -> T
Read a T in [BE-bit, BE-byte] order using bits bits from byte_offset, panicking on an invalid bit count or out of bounds
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn read_be_aligned_bits<T: Read>(&mut self, bits: usize) -> T
pub fn read_be_aligned_bits<T: Read>(&mut self, bits: usize) -> T
Read the next T in [BE-bit, BE-byte] order using bits bits, panicking on an unaligned cursor, invalid bit count, or out of bounds, advancing the internal cursor
§Panics
All semantics of the corresponding function for the type apply
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_u8_be_aligned_at_unchecked(
&mut self,
byte_offset: usize,
v: u8,
) -> &mut Self
pub unsafe fn write_u8_be_aligned_at_unchecked( &mut self, byte_offset: usize, v: u8, ) -> &mut Self
Write a u8 in [BE-bit, BE-byte] order at byte_offset without performing bound checks
§Safety
- This is UB if
byte_offset + 0 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 0 >= self.bytes().len()
Sourcepub unsafe fn write_u8_be_aligned_unchecked(&mut self, v: u8) -> &mut Self
pub unsafe fn write_u8_be_aligned_unchecked(&mut self, v: u8) -> &mut Self
Write the next u8 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 0 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 0 >= self.bytes().len()
Sourcepub unsafe fn write_u8_be_at_unchecked(
&mut self,
offset: usize,
v: u8,
) -> &mut Self
pub unsafe fn write_u8_be_at_unchecked( &mut self, offset: usize, v: u8, ) -> &mut Self
Write a u8 in [BE-bit, BE-byte] order at offset without performing bound checks
§Safety
- This is UB if
(offset / 8) + 0 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 0 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
Sourcepub unsafe fn write_u8_be_unchecked(&mut self, v: u8) -> &mut Self
pub unsafe fn write_u8_be_unchecked(&mut self, v: u8) -> &mut Self
Write the next u8 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 0 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 0 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
Sourcepub fn try_write_u8_be_aligned_at(
&mut self,
byte_offset: usize,
v: u8,
) -> Result<&mut Self>
pub fn try_write_u8_be_aligned_at( &mut self, byte_offset: usize, v: u8, ) -> Result<&mut Self>
Write a u8 in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 0 >= self.bytes().len()
- if
Sourcepub fn try_write_u8_be_aligned(&mut self, v: u8) -> Result<&mut Self>
pub fn try_write_u8_be_aligned(&mut self, v: u8) -> Result<&mut Self>
Write the next u8 in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 0 >= self.bytes().len()
- if
Sourcepub fn try_write_u8_be_at(&mut self, offset: usize, v: u8) -> Result<&mut Self>
pub fn try_write_u8_be_at(&mut self, offset: usize, v: u8) -> Result<&mut Self>
Write a u8 in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 0 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
- if
Sourcepub fn try_write_u8_be(&mut self, v: u8) -> Result<&mut Self>
pub fn try_write_u8_be(&mut self, v: u8) -> Result<&mut Self>
Write the next u8 in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 0 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
- if
Sourcepub fn write_u8_be_aligned_at(&mut self, byte_offset: usize, v: u8) -> &mut Self
pub fn write_u8_be_aligned_at(&mut self, byte_offset: usize, v: u8) -> &mut Self
Write a u8 in [BE-bit, BE-byte] order at byte_offset panicking on out of bounds
§Panics
- Panics if
byte_offset + 0 >= self.bytes().len()
Sourcepub fn write_u8_be_aligned(&mut self, v: u8) -> &mut Self
pub fn write_u8_be_aligned(&mut self, v: u8) -> &mut Self
Write the next u8 in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 0 >= self.bytes().len()
Sourcepub fn write_u8_be_at(&mut self, offset: usize, v: u8) -> &mut Self
pub fn write_u8_be_at(&mut self, offset: usize, v: u8) -> &mut Self
Write a u8 in [BE-bit, BE-byte] order at offset panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 0 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 1 >= self.bytes().len()
Sourcepub fn write_u8_be(&mut self, v: u8) -> &mut Self
pub fn write_u8_be(&mut self, v: u8) -> &mut Self
Write the next u8 in [BE-bit, BE-byte] order panicking on out of bounds
§Panics
- Panics if
(self.pos() / 8) + 0 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 1 >= self.bytes().len()
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_u16_be_aligned_at_unchecked(
&mut self,
byte_offset: usize,
v: u16,
) -> &mut Self
pub unsafe fn write_u16_be_aligned_at_unchecked( &mut self, byte_offset: usize, v: u16, ) -> &mut Self
Write a u16 in [BE-bit, BE-byte] order at byte_offset without performing bound checks
§Safety
- This is UB if
byte_offset + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 1 >= self.bytes().len()
Sourcepub unsafe fn write_u16_be_aligned_unchecked(&mut self, v: u16) -> &mut Self
pub unsafe fn write_u16_be_aligned_unchecked(&mut self, v: u16) -> &mut Self
Write the next u16 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 1 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 1 >= self.bytes().len()
Sourcepub unsafe fn write_u16_be_at_unchecked(
&mut self,
offset: usize,
v: u16,
) -> &mut Self
pub unsafe fn write_u16_be_at_unchecked( &mut self, offset: usize, v: u16, ) -> &mut Self
Write a u16 in [BE-bit, BE-byte] order at offset without performing bound checks
§Safety
- This is UB if
(offset / 8) + 1 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 1 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
Sourcepub unsafe fn write_u16_be_unchecked(&mut self, v: u16) -> &mut Self
pub unsafe fn write_u16_be_unchecked(&mut self, v: u16) -> &mut Self
Write the next u16 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 1 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 1 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
Sourcepub fn try_write_u16_be_aligned_at(
&mut self,
byte_offset: usize,
v: u16,
) -> Result<&mut Self>
pub fn try_write_u16_be_aligned_at( &mut self, byte_offset: usize, v: u16, ) -> Result<&mut Self>
Write a u16 in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 1 >= self.bytes().len()
- if
Sourcepub fn try_write_u16_be_aligned(&mut self, v: u16) -> Result<&mut Self>
pub fn try_write_u16_be_aligned(&mut self, v: u16) -> Result<&mut Self>
Write the next u16 in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 1 >= self.bytes().len()
- if
Sourcepub fn try_write_u16_be_at(
&mut self,
offset: usize,
v: u16,
) -> Result<&mut Self>
pub fn try_write_u16_be_at( &mut self, offset: usize, v: u16, ) -> Result<&mut Self>
Write a u16 in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 1 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
- if
Sourcepub fn try_write_u16_be(&mut self, v: u16) -> Result<&mut Self>
pub fn try_write_u16_be(&mut self, v: u16) -> Result<&mut Self>
Write the next u16 in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 1 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
- if
Sourcepub fn write_u16_be_aligned_at(
&mut self,
byte_offset: usize,
v: u16,
) -> &mut Self
pub fn write_u16_be_aligned_at( &mut self, byte_offset: usize, v: u16, ) -> &mut Self
Write a u16 in [BE-bit, BE-byte] order at byte_offset panicking on out of bounds
§Panics
- Panics if
byte_offset + 1 >= self.bytes().len()
Sourcepub fn write_u16_be_aligned(&mut self, v: u16) -> &mut Self
pub fn write_u16_be_aligned(&mut self, v: u16) -> &mut Self
Write the next u16 in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 1 >= self.bytes().len()
Sourcepub fn write_u16_be_at(&mut self, offset: usize, v: u16) -> &mut Self
pub fn write_u16_be_at(&mut self, offset: usize, v: u16) -> &mut Self
Write a u16 in [BE-bit, BE-byte] order at offset panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 1 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 2 >= self.bytes().len()
Sourcepub fn write_u16_be(&mut self, v: u16) -> &mut Self
pub fn write_u16_be(&mut self, v: u16) -> &mut Self
Write the next u16 in [BE-bit, BE-byte] order panicking on out of bounds
§Panics
- Panics if
(self.pos() / 8) + 1 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 2 >= self.bytes().len()
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_u32_be_aligned_at_unchecked(
&mut self,
byte_offset: usize,
v: u32,
) -> &mut Self
pub unsafe fn write_u32_be_aligned_at_unchecked( &mut self, byte_offset: usize, v: u32, ) -> &mut Self
Write a u32 in [BE-bit, BE-byte] order at byte_offset without performing bound checks
§Safety
- This is UB if
byte_offset + 3 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 3 >= self.bytes().len()
Sourcepub unsafe fn write_u32_be_aligned_unchecked(&mut self, v: u32) -> &mut Self
pub unsafe fn write_u32_be_aligned_unchecked(&mut self, v: u32) -> &mut Self
Write the next u32 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 3 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 3 >= self.bytes().len()
Sourcepub unsafe fn write_u32_be_at_unchecked(
&mut self,
offset: usize,
v: u32,
) -> &mut Self
pub unsafe fn write_u32_be_at_unchecked( &mut self, offset: usize, v: u32, ) -> &mut Self
Write a u32 in [BE-bit, BE-byte] order at offset without performing bound checks
§Safety
- This is UB if
(offset / 8) + 3 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 3 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
Sourcepub unsafe fn write_u32_be_unchecked(&mut self, v: u32) -> &mut Self
pub unsafe fn write_u32_be_unchecked(&mut self, v: u32) -> &mut Self
Write the next u32 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 3 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 3 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
Sourcepub fn try_write_u32_be_aligned_at(
&mut self,
byte_offset: usize,
v: u32,
) -> Result<&mut Self>
pub fn try_write_u32_be_aligned_at( &mut self, byte_offset: usize, v: u32, ) -> Result<&mut Self>
Write a u32 in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 3 >= self.bytes().len()
- if
Sourcepub fn try_write_u32_be_aligned(&mut self, v: u32) -> Result<&mut Self>
pub fn try_write_u32_be_aligned(&mut self, v: u32) -> Result<&mut Self>
Write the next u32 in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 3 >= self.bytes().len()
- if
Sourcepub fn try_write_u32_be_at(
&mut self,
offset: usize,
v: u32,
) -> Result<&mut Self>
pub fn try_write_u32_be_at( &mut self, offset: usize, v: u32, ) -> Result<&mut Self>
Write a u32 in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 3 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
- if
Sourcepub fn try_write_u32_be(&mut self, v: u32) -> Result<&mut Self>
pub fn try_write_u32_be(&mut self, v: u32) -> Result<&mut Self>
Write the next u32 in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 3 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
- if
Sourcepub fn write_u32_be_aligned_at(
&mut self,
byte_offset: usize,
v: u32,
) -> &mut Self
pub fn write_u32_be_aligned_at( &mut self, byte_offset: usize, v: u32, ) -> &mut Self
Write a u32 in [BE-bit, BE-byte] order at byte_offset panicking on out of bounds
§Panics
- Panics if
byte_offset + 3 >= self.bytes().len()
Sourcepub fn write_u32_be_aligned(&mut self, v: u32) -> &mut Self
pub fn write_u32_be_aligned(&mut self, v: u32) -> &mut Self
Write the next u32 in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 3 >= self.bytes().len()
Sourcepub fn write_u32_be_at(&mut self, offset: usize, v: u32) -> &mut Self
pub fn write_u32_be_at(&mut self, offset: usize, v: u32) -> &mut Self
Write a u32 in [BE-bit, BE-byte] order at offset panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 3 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 4 >= self.bytes().len()
Sourcepub fn write_u32_be(&mut self, v: u32) -> &mut Self
pub fn write_u32_be(&mut self, v: u32) -> &mut Self
Write the next u32 in [BE-bit, BE-byte] order panicking on out of bounds
§Panics
- Panics if
(self.pos() / 8) + 3 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 4 >= self.bytes().len()
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_u64_be_aligned_at_unchecked(
&mut self,
byte_offset: usize,
v: u64,
) -> &mut Self
pub unsafe fn write_u64_be_aligned_at_unchecked( &mut self, byte_offset: usize, v: u64, ) -> &mut Self
Write a u64 in [BE-bit, BE-byte] order at byte_offset without performing bound checks
§Safety
- This is UB if
byte_offset + 7 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 7 >= self.bytes().len()
Sourcepub unsafe fn write_u64_be_aligned_unchecked(&mut self, v: u64) -> &mut Self
pub unsafe fn write_u64_be_aligned_unchecked(&mut self, v: u64) -> &mut Self
Write the next u64 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 7 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 7 >= self.bytes().len()
Sourcepub unsafe fn write_u64_be_at_unchecked(
&mut self,
offset: usize,
v: u64,
) -> &mut Self
pub unsafe fn write_u64_be_at_unchecked( &mut self, offset: usize, v: u64, ) -> &mut Self
Write a u64 in [BE-bit, BE-byte] order at offset without performing bound checks
§Safety
- This is UB if
(offset / 8) + 7 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 7 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
Sourcepub unsafe fn write_u64_be_unchecked(&mut self, v: u64) -> &mut Self
pub unsafe fn write_u64_be_unchecked(&mut self, v: u64) -> &mut Self
Write the next u64 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 7 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 7 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
Sourcepub fn try_write_u64_be_aligned_at(
&mut self,
byte_offset: usize,
v: u64,
) -> Result<&mut Self>
pub fn try_write_u64_be_aligned_at( &mut self, byte_offset: usize, v: u64, ) -> Result<&mut Self>
Write a u64 in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 7 >= self.bytes().len()
- if
Sourcepub fn try_write_u64_be_aligned(&mut self, v: u64) -> Result<&mut Self>
pub fn try_write_u64_be_aligned(&mut self, v: u64) -> Result<&mut Self>
Write the next u64 in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 7 >= self.bytes().len()
- if
Sourcepub fn try_write_u64_be_at(
&mut self,
offset: usize,
v: u64,
) -> Result<&mut Self>
pub fn try_write_u64_be_at( &mut self, offset: usize, v: u64, ) -> Result<&mut Self>
Write a u64 in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 7 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
- if
Sourcepub fn try_write_u64_be(&mut self, v: u64) -> Result<&mut Self>
pub fn try_write_u64_be(&mut self, v: u64) -> Result<&mut Self>
Write the next u64 in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 7 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
- if
Sourcepub fn write_u64_be_aligned_at(
&mut self,
byte_offset: usize,
v: u64,
) -> &mut Self
pub fn write_u64_be_aligned_at( &mut self, byte_offset: usize, v: u64, ) -> &mut Self
Write a u64 in [BE-bit, BE-byte] order at byte_offset panicking on out of bounds
§Panics
- Panics if
byte_offset + 7 >= self.bytes().len()
Sourcepub fn write_u64_be_aligned(&mut self, v: u64) -> &mut Self
pub fn write_u64_be_aligned(&mut self, v: u64) -> &mut Self
Write the next u64 in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 7 >= self.bytes().len()
Sourcepub fn write_u64_be_at(&mut self, offset: usize, v: u64) -> &mut Self
pub fn write_u64_be_at(&mut self, offset: usize, v: u64) -> &mut Self
Write a u64 in [BE-bit, BE-byte] order at offset panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 7 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 8 >= self.bytes().len()
Sourcepub fn write_u64_be(&mut self, v: u64) -> &mut Self
pub fn write_u64_be(&mut self, v: u64) -> &mut Self
Write the next u64 in [BE-bit, BE-byte] order panicking on out of bounds
§Panics
- Panics if
(self.pos() / 8) + 7 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 8 >= self.bytes().len()
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_u128_be_aligned_at_unchecked(
&mut self,
byte_offset: usize,
v: u128,
) -> &mut Self
pub unsafe fn write_u128_be_aligned_at_unchecked( &mut self, byte_offset: usize, v: u128, ) -> &mut Self
Write a u128 in [BE-bit, BE-byte] order at byte_offset without performing bound checks
§Safety
- This is UB if
byte_offset + 15 >= self.bytes().len()
§Panics
- Panics in debug mode if
byte_offset + 15 >= self.bytes().len()
Sourcepub unsafe fn write_u128_be_aligned_unchecked(&mut self, v: u128) -> &mut Self
pub unsafe fn write_u128_be_aligned_unchecked(&mut self, v: u128) -> &mut Self
Write the next u128 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- The internal cursor must be byte-aligned (
self.is_aligned()) - This is UB if
self.byte_pos() + 15 >= self.bytes().len()
§Panics
- Panics in debug mode if the internal cursor is not byte-aligned (
!self.is_aligned()) - Panics in debug mode if
self.byte_pos() + 15 >= self.bytes().len()
Sourcepub unsafe fn write_u128_be_at_unchecked(
&mut self,
offset: usize,
v: u128,
) -> &mut Self
pub unsafe fn write_u128_be_at_unchecked( &mut self, offset: usize, v: u128, ) -> &mut Self
Write a u128 in [BE-bit, BE-byte] order at offset without performing bound checks
§Safety
- This is UB if
(offset / 8) + 15 >= self.bytes().len() - This is UB if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
§Panics
- Panics in debug mode if
(offset / 8) + 15 >= self.bytes().len() - Panics in debug mode if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
Sourcepub unsafe fn write_u128_be_unchecked(&mut self, v: u128) -> &mut Self
pub unsafe fn write_u128_be_unchecked(&mut self, v: u128) -> &mut Self
Write the next u128 in [BE-bit, BE-byte] order without performing bound checks, advancing the internal cursor
§Safety
- This is UB if
(self.pos() / 8) + 15 >= self.bytes().len() - This is UB if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
§Panics
- Panics in debug mode if
(self.pos() / 8) + 15 >= self.bytes().len() - Panics in debug mode if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
Sourcepub fn try_write_u128_be_aligned_at(
&mut self,
byte_offset: usize,
v: u128,
) -> Result<&mut Self>
pub fn try_write_u128_be_aligned_at( &mut self, byte_offset: usize, v: u128, ) -> Result<&mut Self>
Write a u128 in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
byte_offset + 15 >= self.bytes().len()
- if
Sourcepub fn try_write_u128_be_aligned(&mut self, v: u128) -> Result<&mut Self>
pub fn try_write_u128_be_aligned(&mut self, v: u128) -> Result<&mut Self>
Write the next u128 in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
- Returns
Error::Unaligned- if the internal cursor is not byte-aligned (
!self.is_aligned())
- if the internal cursor is not byte-aligned (
- Returns
Error::OutOfBounds- if
self.byte_pos() + 15 >= self.bytes().len()
- if
Sourcepub fn try_write_u128_be_at(
&mut self,
offset: usize,
v: u128,
) -> Result<&mut Self>
pub fn try_write_u128_be_at( &mut self, offset: usize, v: u128, ) -> Result<&mut Self>
Write a u128 in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
- Returns
Error::OutOfBounds- if
(offset / 8) + 15 >= self.bytes().len() - if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
- if
Sourcepub fn try_write_u128_be(&mut self, v: u128) -> Result<&mut Self>
pub fn try_write_u128_be(&mut self, v: u128) -> Result<&mut Self>
Write the next u128 in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
- Returns
Error::OutOfBounds- if
(self.pos() / 8) + 15 >= self.bytes().len() - if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
- if
Sourcepub fn write_u128_be_aligned_at(
&mut self,
byte_offset: usize,
v: u128,
) -> &mut Self
pub fn write_u128_be_aligned_at( &mut self, byte_offset: usize, v: u128, ) -> &mut Self
Write a u128 in [BE-bit, BE-byte] order at byte_offset panicking on out of bounds
§Panics
- Panics if
byte_offset + 15 >= self.bytes().len()
Sourcepub fn write_u128_be_aligned(&mut self, v: u128) -> &mut Self
pub fn write_u128_be_aligned(&mut self, v: u128) -> &mut Self
Write the next u128 in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
- if the internal cursor is not byte-aligned (
!self.is_aligned()) - if
self.byte_pos() + 15 >= self.bytes().len()
Sourcepub fn write_u128_be_at(&mut self, offset: usize, v: u128) -> &mut Self
pub fn write_u128_be_at(&mut self, offset: usize, v: u128) -> &mut Self
Write a u128 in [BE-bit, BE-byte] order at offset panicking on out of bounds
§Panics
- Panics if
(offset / 8) + 15 >= self.bytes().len() - Panics if
(offset % 8 != 0) && (offset / 8) + 16 >= self.bytes().len()
Sourcepub fn write_u128_be(&mut self, v: u128) -> &mut Self
pub fn write_u128_be(&mut self, v: u128) -> &mut Self
Write the next u128 in [BE-bit, BE-byte] order panicking on out of bounds
§Panics
- Panics if
(self.pos() / 8) + 15 >= self.bytes().len() - Panics if
(self.pos() % 8 != 0) && (self.pos() / 8) + 16 >= self.bytes().len()
Source§impl<S: StorageMut> BitBuf<S>
impl<S: StorageMut> BitBuf<S>
Sourcepub unsafe fn write_be_aligned_at_unchecked<T: Write>(
&mut self,
byte_offset: usize,
v: T,
) -> &mut Self
pub unsafe fn write_be_aligned_at_unchecked<T: Write>( &mut self, byte_offset: usize, v: T, ) -> &mut Self
Sourcepub unsafe fn write_be_aligned_unchecked<T: Write>(&mut self, v: T) -> &mut Self
pub unsafe fn write_be_aligned_unchecked<T: Write>(&mut self, v: T) -> &mut Self
Sourcepub unsafe fn write_be_at_unchecked<T: Write>(
&mut self,
offset: usize,
v: T,
) -> &mut Self
pub unsafe fn write_be_at_unchecked<T: Write>( &mut self, offset: usize, v: T, ) -> &mut Self
Sourcepub unsafe fn write_be_unchecked<T: Write>(&mut self, v: T) -> &mut Self
pub unsafe fn write_be_unchecked<T: Write>(&mut self, v: T) -> &mut Self
Sourcepub fn try_write_be_aligned_at<T: Write>(
&mut self,
byte_offset: usize,
v: T,
) -> Result<&mut Self>
pub fn try_write_be_aligned_at<T: Write>( &mut self, byte_offset: usize, v: T, ) -> Result<&mut Self>
Write a T in [BE-bit, BE-byte] order at byte_offset while performing bound checks
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_write_be_aligned<T: Write>(&mut self, v: T) -> Result<&mut Self>
pub fn try_write_be_aligned<T: Write>(&mut self, v: T) -> Result<&mut Self>
Write the next T in [BE-bit, BE-byte] order while performing alignment and bound checks, advancing the internal cursor
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_write_be_at<T: Write>(
&mut self,
offset: usize,
v: T,
) -> Result<&mut Self>
pub fn try_write_be_at<T: Write>( &mut self, offset: usize, v: T, ) -> Result<&mut Self>
Write a T in [BE-bit, BE-byte] order at offset while performing bound checks
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn try_write_be<T: Write>(&mut self, v: T) -> Result<&mut Self>
pub fn try_write_be<T: Write>(&mut self, v: T) -> Result<&mut Self>
Write the next T in [BE-bit, BE-byte] order while performing bound checks, advancing the internal cursor
§Errors
All semantics of the corresponding function for the type apply
Sourcepub fn write_be_aligned_at<T: Write>(
&mut self,
byte_offset: usize,
v: T,
) -> &mut Self
pub fn write_be_aligned_at<T: Write>( &mut self, byte_offset: usize, v: T, ) -> &mut Self
Write a T in [BE-bit, BE-byte] order at byte_offset, panicking on out of bounds
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn write_be_aligned<T: Write>(&mut self, v: T) -> &mut Self
pub fn write_be_aligned<T: Write>(&mut self, v: T) -> &mut Self
Write the next T in [BE-bit, BE-byte] order panicking on an unaligned cursor or out of bounds, advancing the internal cursor
§Panics
All semantics of the corresponding function for the type apply
Sourcepub fn write_be_at<T: Write>(&mut self, offset: usize, v: T) -> &mut Self
pub fn write_be_at<T: Write>(&mut self, offset: usize, v: T) -> &mut Self
Write a T in [BE-bit, BE-byte] order at offset, panicking on out of bounds
§Panics
All semantics of the corresponding function for the type apply