Skip to main content

CheckBytes

Trait CheckBytes 

Source
pub unsafe trait CheckBytes {
    // Required method
    fn check_at(bytes: &[u8], base: usize) -> Result<(), String>;
}
Available on crate feature archive only.
Expand description

Validates an archived value.

This is the in-tree replacement for rkyv’s check_archived_root. It walks the whole graph once, proving every offset, length, and range in-bounds, and must run before the first access.

§Safety

Returning success must prove that bytes at base holds a fully valid, aligned Self, including its complete skeleton and every reachable value. All references exposed by safe accessors must remain inside bytes, with valid alignment and representation, for the lifetime of that immutable buffer. Implementations must not allow safe relocation of relative pointers or interior mutation that invalidates these guarantees.

ⓘ
use rustbinary::archive_codec::CheckBytes;
struct Unchecked(bool);
impl CheckBytes for Unchecked {
    fn check_at(_: &[u8], _: usize) -> Result<(), String> { Ok(()) }
}

Required Methods§

Source

fn check_at(bytes: &[u8], base: usize) -> Result<(), String>

Validates the archived value at base inside bytes.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§