pub struct BytesReader<'r>(/* private fields */);
Implementations§
Source§impl<'r> BytesReader<'r>
impl<'r> BytesReader<'r>
Sourcepub unsafe fn as_utf8_unchecked(&self) -> &str
pub unsafe fn as_utf8_unchecked(&self) -> &str
Converts self to a string slice without checking that the string contains valid UTF-8.
§Safety
This function is unsafe because it does not check that the bytes passed to
it are valid UTF-8. If this constraint is violated, undefined behavior
results, as the rest of Rust assumes that &str
s are valid UTF-8.
Source§impl<'r> BytesReader<'r>
impl<'r> BytesReader<'r>
Sourcepub fn calc_raw_data_hash(&self) -> Byte32
pub fn calc_raw_data_hash(&self) -> Byte32
Calculates the hash for raw data in Bytes
.
Returns the empty hash if no data, otherwise, calculates the hash of the data and returns it.
Source§impl<'r> BytesReader<'r>
impl<'r> BytesReader<'r>
pub const ITEM_SIZE: usize = 1usize
pub fn total_size(&self) -> usize
pub fn item_count(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, idx: usize) -> Option<ByteReader<'r>>
pub fn get_unchecked(&self, idx: usize) -> ByteReader<'r>
pub fn raw_data(&self) -> &'r [u8] ⓘ
Trait Implementations§
Source§impl<'r> Clone for BytesReader<'r>
impl<'r> Clone for BytesReader<'r>
Source§fn clone(&self) -> BytesReader<'r>
fn clone(&self) -> BytesReader<'r>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'r> Debug for BytesReader<'r>
impl<'r> Debug for BytesReader<'r>
Source§impl<'r> Display for BytesReader<'r>
impl<'r> Display for BytesReader<'r>
Source§impl<'r> LowerHex for BytesReader<'r>
impl<'r> LowerHex for BytesReader<'r>
Source§impl<'r> Reader<'r> for BytesReader<'r>
impl<'r> Reader<'r> for BytesReader<'r>
const NAME: &'static str = "BytesReader"
type Entity = Bytes
fn to_entity(&self) -> <BytesReader<'r> as Reader<'r>>::Entity
fn new_unchecked(slice: &'r [u8]) -> BytesReader<'r>
fn as_slice(&self) -> &'r [u8] ⓘ
fn verify(slice: &[u8], _compatible: bool) -> Result<(), VerificationError>
fn from_slice(slice: &'r [u8]) -> Result<Self, VerificationError>
fn from_compatible_slice(slice: &'r [u8]) -> Result<Self, VerificationError>
Source§impl<'r> Unpack<Bytes> for BytesReader<'r>
impl<'r> Unpack<Bytes> for BytesReader<'r>
impl<'r> Copy for BytesReader<'r>
Auto Trait Implementations§
impl<'r> Freeze for BytesReader<'r>
impl<'r> RefUnwindSafe for BytesReader<'r>
impl<'r> Send for BytesReader<'r>
impl<'r> Sync for BytesReader<'r>
impl<'r> Unpin for BytesReader<'r>
impl<'r> UnwindSafe for BytesReader<'r>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<'r, R> FromSliceShouldBeOk<'r> for Rwhere
R: Reader<'r>,
impl<'r, R> FromSliceShouldBeOk<'r> for Rwhere
R: Reader<'r>,
Source§fn from_slice_should_be_ok(slice: &'r [u8]) -> R
fn from_slice_should_be_ok(slice: &'r [u8]) -> R
Unwraps the result of
from_slice(..)
with confidence and we assume that it’s impossible to fail.Source§fn from_compatible_slice_should_be_ok(slice: &'r [u8]) -> R
fn from_compatible_slice_should_be_ok(slice: &'r [u8]) -> R
Unwraps the result of
from_compatible_slice(..)
with confidence and we assume that it’s impossible to fail.