devela::_dep::rkyv::validation

Trait ArchiveContext

pub unsafe trait ArchiveContext<E = <Self as Fallible>::Error> {
    // Required methods
    fn check_subtree_ptr(
        &mut self,
        ptr: *const u8,
        layout: &Layout,
    ) -> Result<(), E> ;
    unsafe fn push_subtree_range(
        &mut self,
        root: *const u8,
        end: *const u8,
    ) -> Result<Range<usize>, E> ;
    unsafe fn pop_subtree_range(&mut self, range: Range<usize>) -> Result<(), E> ;
}
Available on crate feature dep_rkyv only.
Expand description

A context that can validate nonlocal archive memory.

§Safety

check_subtree_ptr must only return true if ptr is located entirely within the subtree range and is safe to dereference.

Required Methods§

fn check_subtree_ptr( &mut self, ptr: *const u8, layout: &Layout, ) -> Result<(), E>

Checks that the given data address and layout is located completely within the subtree range.

unsafe fn push_subtree_range( &mut self, root: *const u8, end: *const u8, ) -> Result<Range<usize>, E>

Pushes a new subtree range onto the validator and starts validating it.

After calling push_subtree_range, the validator will have a subtree range starting at the original start and ending at root. After popping the returned range, the validator will have a subtree range starting at end and ending at the original end.

§Safety

root and end must be located inside the archive.

unsafe fn pop_subtree_range(&mut self, range: Range<usize>) -> Result<(), E>

Pops the given range, restoring the original state with the pushed range removed.

If the range was not popped in reverse order, an error is returned.

§Safety

range must be a range returned from this validator.

Implementors§

§

impl<A, S, E> ArchiveContext<E> for Validator<A, S>
where A: ArchiveContext<E>,

§

impl<E> ArchiveContext<E> for ArchiveValidator<'_>
where E: Source,

§

impl<T, E> ArchiveContext<E> for Strategy<T, E>
where T: ArchiveContext<E> + ?Sized,