Struct trackable::History[][src]

pub struct History<Event>(_);

The tracking history of a target.

A history is a sequence of the tracked events.

Examples

use std::fmt::{Display, Formatter, Result};
use trackable::History;

struct Event(&'static str);
impl Display for Event {
    fn fmt(&self, f: &mut Formatter) -> Result {
        write!(f, "event: {}", self.0)
    }
}

let mut history = History::new();
history.add(Event("foo"));
history.add(Event("bar"));

assert_eq!(format!("\n{}", history), r#"
HISTORY:
  [0] event: foo
  [1] event: bar
"#);

Implementations

impl<Event> History<Event>[src]

pub fn new() -> History<Event>[src]

Makes an empty history.

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

Adds an event to the tail of this history.

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

Returns the tracked events in this history.

Trait Implementations

impl<Event> Clone for History<Event> where
    Event: Clone
[src]

impl<Event> Debug for History<Event> where
    Event: Debug
[src]

impl<Event> Default for History<Event>[src]

impl<'de, Event> Deserialize<'de> for History<Event> where
    Event: Deserialize<'de>, 
[src]

impl<Event> Display for History<Event> where
    Event: Display
[src]

impl<Event> Serialize for History<Event> where
    Event: Serialize
[src]

Auto Trait Implementations

impl<Event> RefUnwindSafe for History<Event> where
    Event: RefUnwindSafe

impl<Event> Send for History<Event> where
    Event: Send

impl<Event> Sync for History<Event> where
    Event: Sync

impl<Event> Unpin for History<Event> where
    Event: Unpin

impl<Event> UnwindSafe for History<Event> where
    Event: UnwindSafe

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[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> ToString for T where
    T: Display + ?Sized
[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.