Skip to main content

Mode

Enum Mode 

Source
pub enum Mode {
    ChangeNothing,
    InjectChecks(CheckSettings),
    EmbedSpecs,
}

Variants§

§

ChangeNothing

Make no changes to the code.

§

InjectChecks(CheckSettings)

Inject code to enable compile-time and/or runtime checks.

§

EmbedSpecs

Embed spec elements as new items without changing existing code.

Implementations§

Source§

impl Mode

Source

pub fn instrument_item_struct( &self, spec: DataSpec, item_struct: ItemStruct, ) -> Result<TokenStream>

Source

pub fn instrument_item_enum( &self, spec: DataSpec, item_enum: ItemEnum, ) -> Result<TokenStream>

Source§

impl Mode

Source

pub fn instrument_fn( &self, spec: &Spec, sig: &Signature, body: &mut Block, ) -> Result<()>

Source

pub fn build_precondition_fn_sig(prefix: &str, sig: &Signature) -> Signature

Source

pub fn build_postcondition_fn_sig(prefix: &str, sig: &Signature) -> Signature

Source

pub fn build_qualifier_const_item<SomeConstItem: Parse>( attrs: &[Attribute], prefix: &str, qualifiers: FnQualifiers, fn_ident: &Ident, ) -> SomeConstItem

Source

pub fn build_qualifier_check_stmt( fn_ident: &Ident, impl_type: &Type, trait_path: &Path, ) -> Stmt

Source

pub fn build_precondition_fn_body( requires: &[Condition], maintains: &[Condition], ) -> Block

Source

pub fn build_postcondition_fn_body( maintains: &[Condition], captures: &[Capture], ensures: &[PostCondition], ) -> Result<Block>

Source§

impl Mode

Source

pub fn instrument_impl( &self, spec: DataSpec, the_impl: ItemImpl, ) -> Result<ItemImpl>

Expand items inside an inherent impl.

Reasons why impl functions must be treated differently from free-standing functions:

  • The __anodized_fn_try_* function must be qualified as Self:: inside an impl.
Source§

impl Mode

Source

pub fn instrument_loops_in_fn_body(&self, body: &mut Block) -> Result<()>

Source

pub fn instrument_expr_while(&self, spec: LoopSpec, expr_while: &mut ExprWhile)

Source

pub fn instrument_expr_for_loop( &self, spec: LoopSpec, expr_for_loop: &mut ExprForLoop, )

Source§

impl Mode

Source

pub fn instrument_trait( &self, spec: DataSpec, the_trait: ItemTrait, ) -> Result<ItemTrait>

Expand trait items by mangling each method and adding a wrapper default impl.

Mangling a function involves the following:

  1. Rename the function following the pattern: fn add -> fn __anodized_add.
  2. Make a new function with the original name that has a default impl; the default impl performs runtime validation and calls the mangled function.
Source

pub fn instrument_trait_impl( &self, spec: DataSpec, the_impl: ItemImpl, ) -> Result<ItemImpl>

Expand impl items by mangling methods for trait impls.

The #[spec] attribute on an impl fn must narrow the #[spec] of the trait fn:

  • The impl’s preconditions must follow from the trait’s preconditions.
  • The impl’s postconditions must entail the trait’s postconditions.
Source§

impl Mode

Source

pub fn changes_anything(&self) -> bool

Source

pub fn emits_try_fn(&self) -> bool

Source

pub fn with_try_fn(&self, value: bool) -> Self

Source

pub fn instrument_item_fn( &self, spec: Spec, item_fn: ItemFn, ) -> Result<TokenStream>

Source

pub fn instrument_item_impl( &self, spec: DataSpec, item_impl: ItemImpl, ) -> Result<TokenStream>

Source

pub fn instrument_item_trait( &self, spec: DataSpec, item_trait: ItemTrait, ) -> Result<TokenStream>

Source

pub fn instrument_item_trait_impl( &self, spec: DataSpec, item_impl: ItemImpl, ) -> Result<TokenStream>

Trait Implementations§

Source§

impl Clone for Mode

Source§

fn clone(&self) -> Mode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Mode

§

impl RefUnwindSafe for Mode

§

impl Send for Mode

§

impl Sync for Mode

§

impl Unpin for Mode

§

impl UnsafeUnpin for Mode

§

impl UnwindSafe for Mode

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.