Skip to main content

SharedContext

Trait SharedContext 

Source
pub trait SharedContext<E = <Self as Fallible>::Error> {
    // Required methods
    fn start_shared(
        &mut self,
        shared_type_id: TypeId,
        ptr: ErasedPtr,
        metadata_is_eq: unsafe fn(Metadata, Metadata) -> bool,
    ) -> Result<ValidationState, E>;
    fn finish_shared(
        &mut self,
        shared_type_id: TypeId,
        ptr: ErasedPtr,
    ) -> Result<(), E>;
}
Expand description

A context that can validate shared archive memory.

Shared pointers require this kind of context to validate.

Required Methods§

Source

fn start_shared( &mut self, shared_type_id: TypeId, ptr: ErasedPtr, metadata_is_eq: unsafe fn(Metadata, Metadata) -> bool, ) -> Result<ValidationState, E>

Starts validating the value associated with an erased data pointer and shared pointer type.

The arguments to this method are relatively complex:

  • shared_type_id is the type of the shared pointer to start validating
  • ptr is an erased pointer to the data in the buffer that is shared
  • metadata_is_eq is a comparison function called on potentially-equal data pointers

shared_type_id and ptr are used as a unique key to identify the shared pointer. If the shared context finds another shared pointer with the same shared type ID and data address, it will call metadata_is_eq on the metadata of the existing shared pointer and the metadata of the provided shared pointer.

Returns an error if the value associated with the given address was started with a different type ID.

Source

fn finish_shared( &mut self, shared_type_id: TypeId, ptr: ErasedPtr, ) -> Result<(), E>

Finishes validating the value associated with the given address.

Returns an error if the given address was not pending.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T, E> SharedContext<E> for Strategy<T, E>
where T: SharedContext<E>,

Source§

fn start_shared( &mut self, shared_type_id: TypeId, ptr: ErasedPtr, metadata_is_eq: unsafe fn(Metadata, Metadata) -> bool, ) -> Result<ValidationState, E>

Source§

fn finish_shared( &mut self, shared_type_id: TypeId, ptr: ErasedPtr, ) -> Result<(), E>

Implementors§

Source§

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

Source§

impl<E: Source> SharedContext<E> for SharedValidator