Skip to main content

Chunk

Trait Chunk 

Source
pub trait Chunk<'source>:
    Sized
    + Copy
    + PartialEq
    + Eq {
    const SIZE: usize;

    // Required method
    unsafe fn from_ptr(ptr: *const u8) -> Self;
}
Expand description

A fixed, statically sized chunk of data that can be read from the Source.

This is implemented for u8, as well as byte arrays &[u8; 1] to &[u8; 32].

Required Associated Constants§

Source

const SIZE: usize

Size of the chunk being accessed in bytes.

Required Methods§

Source

unsafe fn from_ptr(ptr: *const u8) -> Self

Create a chunk from a raw byte pointer.

§Safety

Raw byte pointer should point to a valid location in source.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'source, const N: usize> Chunk<'source> for &'source [u8; N]

Source§

const SIZE: usize = N

Source§

unsafe fn from_ptr(ptr: *const u8) -> Self

Source§

impl<'source> Chunk<'source> for u8

Source§

const SIZE: usize = 1

Source§

unsafe fn from_ptr(ptr: *const u8) -> Self

Implementors§