Struct CustomSectionValidator
pub struct CustomSectionValidator { /* private fields */ }Expand description
A validator for the contents of custom sections.
Custom sections in WebAssembly do not affect whether a module is valid, but it can still be useful for debugging and specification purposes to know and test whether a custom section is valid.
For known custom sections specified in the WebAssembly specification, such
as the name custom section or the branch-hint custom section, this
validator will ensure that those contents are valid according to the
specification.
This structure is intended to be used in parallel with a Validator.
After a Payload is fed to a Validator it’s then fed into this with
CustomSectionValidator::payload. Function validation then later invokes
CustomSectionValidator::code_section_entry to ensure the validity of
custom sections referring to contents of function bodies.
Implementations§
§impl CustomSectionValidator
impl CustomSectionValidator
pub fn new() -> CustomSectionValidator
pub fn new() -> CustomSectionValidator
Creates a new validator ready for validating a component or a module.
pub fn payload(
&mut self,
payload: &Payload<'_>,
validator: &Validator,
) -> Result<(), Error>
pub fn payload( &mut self, payload: &Payload<'_>, validator: &Validator, ) -> Result<(), Error>
Validates the payload provided which should already have been
validated with the validator provided.
pub fn current_module_id(&self) -> usize
pub fn current_module_id(&self) -> usize
Gets an id for the current module to pass to
CustomSectionValidator::code_section_entry when the function
contents are ready to be validated.
pub fn code_section_entry(
&self,
module_id: usize,
func_index: u32,
body: &FunctionBody<'_>,
) -> Result<(), Error>
pub fn code_section_entry( &self, module_id: usize, func_index: u32, body: &FunctionBody<'_>, ) -> Result<(), Error>
Validates the contents of body w.r.t. custom sections.
The module_id should have been previously acquired from
CustomSectionValidator::current_module_id. The func_index and
body are specified relative to that module.
This function should only be invoked after the entire module has been
processed with CustomSectionValidator::payload to ensure that all
data is known about all custom sections present.
Trait Implementations§
§impl Default for CustomSectionValidator
impl Default for CustomSectionValidator
§fn default() -> CustomSectionValidator
fn default() -> CustomSectionValidator
Auto Trait Implementations§
impl Freeze for CustomSectionValidator
impl RefUnwindSafe for CustomSectionValidator
impl Send for CustomSectionValidator
impl Sync for CustomSectionValidator
impl Unpin for CustomSectionValidator
impl UnsafeUnpin for CustomSectionValidator
impl UnwindSafe for CustomSectionValidator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more