Enum checkers::Event

source ·
#[non_exhaustive]
pub enum Event {
    Alloc(Request),
    Free(Request),
    AllocZeroed(AllocZeroed),
    Realloc(Realloc),
    AllocFailed,
    AllocZeroedFailed,
    ReallocNull(ReallocNull),
    ReallocFailed,
}
Expand description

Metadata for a single allocation or deallocation.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Alloc(Request)

An allocation.

§

Free(Request)

A deallocation.

§

AllocZeroed(AllocZeroed)

A zerod allocation, with an optional boolean indicates if it is actually zeroed or not.

§

Realloc(Realloc)

A reallocation that moves and resized memory from one location to another.

§

AllocFailed

An allocation failed (produced null).

§

AllocZeroedFailed

A zero allocation that failed (produced null).

§

ReallocNull(ReallocNull)

Allocator was asked to reallocate unallocated memory.

§

ReallocFailed

A reallocation failed (produced null), and the previous region is left unchanged.

Implementations§

source§

impl Event

source

pub fn is_alloc_with<F>(&self, f: F) -> boolwhere F: FnOnce(Region) -> bool,

Test if this event is an allocation which matches the specified predicate.

Examples
use checkers::{Event::*, Request, Region};

let request = Request::without_backtrace(Region::new(100.into(), 100, 4));
let event = Alloc(request);

assert!(event.is_alloc_with(|r| r.size == 100 && r.align == 4));
assert!(!event.is_free_with(|r| r.size == 100 && r.align == 4));
source

pub fn is_free_with<F>(&self, f: F) -> boolwhere F: FnOnce(Region) -> bool,

Test if this event is a deallocation which matches the specified predicate.

Examples
use checkers::{Event::*, Region, Request};

let request = Request::without_backtrace(Region::new(100.into(), 100, 4));
let event = Free(request);

assert!(!event.is_alloc_with(|r| r.size == 100 && r.align == 4));
assert!(event.is_free_with(|r| r.size == 100 && r.align == 4));
source

pub fn is_alloc_zeroed_with<F>(&self, f: F) -> boolwhere F: FnOnce(&AllocZeroed) -> bool,

Test if this event is an allocation which matches the specified predicate.

Examples
use checkers::{Event::*, Request, Region, AllocZeroed};

let event = AllocZeroed(AllocZeroed::new(
    Some(true),
    Request::without_backtrace(Region::new(100.into(), 100, 4))
));

assert!(event.is_alloc_zeroed_with(|r| r.request.region.size == 100 && r.request.region.align == 4));
assert!(!event.is_free_with(|r| r.size == 100 && r.align == 4));
source

pub fn is_realloc_with<F>(&self, f: F) -> boolwhere F: FnOnce(&Realloc) -> bool,

Test if this event is an allocation which matches the specified predicate.

Examples
use checkers::{Event::*, Realloc, Region, Request};

let event = Realloc(Realloc::without_backtrace(
    Some(true),
    Region::new(10.into(), 10, 1),
    Region::new(20.into(), 20, 1)
));

assert!(event.is_realloc_with(|r| r.free.size == 10 && r.alloc.size == 20));
source

pub fn is_failed(&self) -> bool

Test if this event is an allocation which matches the specified predicate.

Examples
use checkers::Event;

assert!(Event::AllocFailed.is_failed());
assert!(Event::AllocZeroedFailed.is_failed());
assert!(Event::ReallocFailed.is_failed());

Trait Implementations§

source§

impl Clone for Event

source§

fn clone(&self) -> Event

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Event

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.