Trait Requirement

Source
pub trait Requirement {
    type Error;

    // Required methods
    fn check(&mut self, vector: Vector);
    fn check_partial(&mut self, vector: Vector, len: u32);
    fn result(self) -> (bool, Result<(), Self::Error>);
    fn results(self) -> (bool, impl Iterator<Item = Result<(), Self::Error>>);
}
Available on crate feature require only.
Expand description

A trait representing a collection of conditions which must be met at least once.

§Methods

  • result - Check if all requirements were met, fails fast
  • results - Iterate over each requirement’s result

Required Associated Types§

Source

type Error

The common error of each requirement!, each error associated with the requirement should either be this error type or implement Into for this error type.

Required Methods§

Source

fn check(&mut self, vector: Vector)

Used internally by the check function

Source

fn check_partial(&mut self, vector: Vector, len: u32)

Used internally by the check function

This operates similarly to Requirement::check but for handling partial loads.

The reason this is necessary is that partial loads pad the register with zeroes to ensure safety, if these zeroes to not meet any requirement then the validator would consider there to be illegal input and flag it as such.

§Arguments
  • vector - The vector to check.
  • len - The length of the data so that the validator knows what to check.
Source

fn result(self) -> (bool, Result<(), Self::Error>)

§Result

Get the result of the requirement check. This will return the first error caught in order of the requirements. If you need to know each unfulfilled requirement see results

§Returns
  1. A bool denoting if all bytes met at least one of the requirements.
  2. Ok(()) if all requirements were met, or the first error (in order of requirements) caught.
Source

fn results(self) -> (bool, impl Iterator<Item = Result<(), Self::Error>>)

§Results

Get an iterator over each requirement result. If you only need to know if the requirements were fulfilled see result.

§Returns
  1. A bool denoting if all bytes met at least one of the requirements.
  2. An iterator over results, in order of the provided requirements.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§