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
impl Mode
pub fn instrument_item_struct( &self, spec: DataSpec, item_struct: ItemStruct, ) -> Result<TokenStream>
pub fn instrument_item_enum( &self, spec: DataSpec, item_enum: ItemEnum, ) -> Result<TokenStream>
Source§impl Mode
impl Mode
pub fn instrument_fn( &self, spec: &Spec, sig: &Signature, body: &mut Block, ) -> Result<()>
pub fn build_precondition_fn_sig(prefix: &str, sig: &Signature) -> Signature
pub fn build_postcondition_fn_sig(prefix: &str, sig: &Signature) -> Signature
pub fn build_qualifier_const_item<SomeConstItem: Parse>( attrs: &[Attribute], prefix: &str, qualifiers: FnQualifiers, fn_ident: &Ident, ) -> SomeConstItem
pub fn build_qualifier_check_stmt( fn_ident: &Ident, impl_type: &Type, trait_path: &Path, ) -> Stmt
pub fn build_precondition_fn_body( requires: &[Condition], maintains: &[Condition], ) -> Block
pub fn build_postcondition_fn_body( maintains: &[Condition], captures: &[Capture], ensures: &[PostCondition], ) -> Result<Block>
Source§impl Mode
impl Mode
pub fn instrument_loops_in_fn_body(&self, body: &mut Block) -> Result<()>
pub fn instrument_expr_while(&self, spec: LoopSpec, expr_while: &mut ExprWhile)
pub fn instrument_expr_for_loop( &self, spec: LoopSpec, expr_for_loop: &mut ExprForLoop, )
Source§impl Mode
impl Mode
Sourcepub fn instrument_trait(
&self,
spec: DataSpec,
the_trait: ItemTrait,
) -> Result<ItemTrait>
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:
- Rename the function following the pattern:
fn add->fn __anodized_add. - Make a new function with the original name that has a default impl; the default impl performs runtime validation and calls the mangled function.
Sourcepub fn instrument_trait_impl(
&self,
spec: DataSpec,
the_impl: ItemImpl,
) -> Result<ItemImpl>
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
impl Mode
pub fn changes_anything(&self) -> bool
pub fn emits_try_fn(&self) -> bool
pub fn with_try_fn(&self, value: bool) -> Self
pub fn instrument_item_fn( &self, spec: Spec, item_fn: ItemFn, ) -> Result<TokenStream>
pub fn instrument_item_impl( &self, spec: DataSpec, item_impl: ItemImpl, ) -> Result<TokenStream>
pub fn instrument_item_trait( &self, spec: DataSpec, item_trait: ItemTrait, ) -> Result<TokenStream>
pub fn instrument_item_trait_impl( &self, spec: DataSpec, item_impl: ItemImpl, ) -> Result<TokenStream>
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more