[][src]Struct checkers::Events

pub struct Events { /* fields omitted */ }

Collections of events.

We use a wrapper type to provide convenience methods for diagnostics.

Methods

impl Events[src]

pub const fn new() -> Self[src]

Construct a new collection of allocations.

pub fn len(&self) -> usize[src]

Get the number of events in this collection.

pub fn is_empty(&self) -> bool[src]

Test if collection is empty.

pub fn capacity(&self) -> usize[src]

Access the capacity of the Events container.

pub fn reserve(&mut self, cap: usize)[src]

Reserve extra capacity for the underlying storage.

pub fn as_slice(&self) -> &[Event][src]

Fetch all allocations as a slice.

pub fn as_slice_mut(&mut self) -> &mut [Event][src]

Fetch all allocations as a slice.

pub fn clear(&mut self)[src]

Clear the collection of events.

pub fn push(&mut self, event: Event)[src]

Push a single event into the collection of events.

Examples

use checkers::{Events, Event, Region};
let mut events = Events::new();
let event = Event::Alloc(Region::new(10.into(), 10, 1));
events.push(event);
assert_eq!(event, events[0]);

pub fn allocs(&self) -> usize[src]

Count the number of allocations in this collection of events.

Examples

use checkers::{Events, Event, Region};
let mut events = Events::new();
events.push(Event::Alloc(Region::new(10.into(), 10, 1)));
assert_eq!(1, events.allocs());
assert_eq!(0, events.frees());

pub fn reallocs(&self) -> usize[src]

Count the number of allocations in this collection of events.

Examples

use checkers::{Events, Event, Region, Realloc};
let mut events = Events::new();

events.push(Event::Realloc(Realloc::new(
    Some(true),
    Region::new(10.into(), 10, 1),
    Region::new(20.into(), 10, 1)
)));

assert_eq!(1, events.reallocs());
assert_eq!(0, events.allocs());
assert_eq!(0, events.frees());

pub fn frees(&self) -> usize[src]

Count the number of frees in this collection of events.

Examples

use checkers::{Events, Event, Region};
let mut events = Events::new();
events.push(Event::Free(Region::new(10.into(), 10, 1)));
assert_eq!(0, events.allocs());
assert_eq!(1, events.frees());

pub fn validate(&self, errors: &mut Vec<Violation>)[src]

Validate the current state and populate the errors collection with any violations found.

See Machine::push for more details on the kind of validation errors that can be raised.

pub fn max_memory_used(&self) -> Result<usize, Violation>[src]

Max amount of memory used according to this event history.

Returns the first violation encountered if the history is not sound.

Examples

use checkers::{Events, Event, Region};
let mut events = Events::new();
events.push(Event::Alloc(Region::new(0x10.into(), 0x10, 1)));
events.push(Event::Alloc(Region::new(0x20.into(), 0x10, 1)));
events.push(Event::Free(Region::new(0x10.into(), 0x10, 1)));
assert_eq!(Ok(0x20), events.max_memory_used());

Trait Implementations

impl Clone for Events[src]

impl Debug for Events[src]

impl Deref for Events[src]

type Target = [Event]

The resulting type after dereferencing.

impl DerefMut for Events[src]

impl<I: SliceIndex<[Event]>> Index<I> for Events[src]

type Output = I::Output

The returned type after indexing.

Auto Trait Implementations

impl RefUnwindSafe for Events

impl Send for Events

impl Sync for Events

impl Unpin for Events

impl UnwindSafe for Events

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.