[][src]Struct racetrack::tracker::Tracker

pub struct Tracker { /* fields omitted */ }

The main tracker class. Construct this in each test if possible, otherwise use a static copy. Any assertions will start with this tracker.

Constraints

  • All arguments and return types must implement ToOwned to allow the function to be tracked.

Example

use racetrack::{Tracker, track_with};

let tracker = Tracker::new();

struct Tracked(Arc<Tracker>);

#[track_with(0)]
impl Tracked {
    fn tracked_method(&self, arg: String) {}
}

let tracked = Tracked(tracker.clone());
tracked.tracked_method("Test".to_string());

tracker
    .assert_that("Tracked::tracked_method")
    .was_called_once()
    .with("Test".to_string());

Methods

impl Tracker[src]

pub fn new() -> Arc<Self>[src]

Construct a new tracker. This returns an Arc since the library expects one everywhere. This allows for use of the tracker in multi-threaded/tasked scenarios.

pub fn assert_that(&self, item: impl Into<String>) -> Assertion[src]

Start an assertion chain.

Arguments

  • item - The key of the method for which assertions should be made. e.g. "Tracked::tracked_method"

pub fn log_call(&self, key: impl Into<String>, call_info: CallInfo)[src]

Log a call to the tracker. This is usually used by the proc macro but can be called manually if the macro doesn't work for your use case.

Arguments

  • key - The key for the method. e.g. Tracked::tracked_method
  • call_info - The call info for the call. May or may not contain arguments and return values.

pub fn clear(&self)[src]

Clear the tracker completely

pub fn print_debug(&self, item: impl Into<String>)[src]

Print the call info for a specific method. To print the whole tracker, use debug format.

Trait Implementations

impl Debug for Tracker[src]

Auto Trait Implementations

impl !RefUnwindSafe for Tracker

impl Send for Tracker

impl Sync for Tracker

impl Unpin for Tracker

impl !UnwindSafe for Tracker

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, 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.