Trait logos::source::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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

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

source§

const SIZE: usize = 1usize

source§

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

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

Implementors§