[][src]Struct pbd::dtc::Tracker

pub struct Tracker { /* fields omitted */ }

Represents a Tacker (a.k.a. MarkerChain)

Methods

impl Tracker[src]

pub fn new(dat_id: String) -> Tracker[src]

Constructs a Tracker (a.k.a. MarkerChain)

Arguments

  • dat_id: String - The unique identifier of the the data being tracked.

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let tracker = Tracker::new("order~clothing~iStore~15150".to_string());
     
    // The genesis Marker is automaically created for you
    assert_eq!(tracker.len(), 1);
}

pub fn add(&mut self, tmstp: u64, act_id: String, dat_id: String)[src]

Appends a new Marker to the end of the Marker Chain. The index of the Marker and hash from the previous Marker are automatically defined when added.

Arguments

  • tmstp: String - The date and time (Unix timestamp) the data came into posession of the Actor.
  • act_id: String - The Unix Epoch time when the DUA was agreed to.
  • dat_id: String - The unique identifier of the the data being tracked.

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let mut tracker = Tracker::new("order~clothing~iStore~15150".to_string());
    tracker.add(1578071239, "notifier~billing~receipt~email".to_string(), "order~clothing~iStore~15150".to_string());
     
    println!("There are {} items in the Marker Chain.", tracker.len());
}

pub fn get(&self, index: usize) -> Option<Marker>[src]

Returns the Marker from the Marker Chain at the specified index.

Arguments

  • index: usize - The index of the Marker.

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let mut tracker = Tracker::new("order~clothing~iStore~15150".to_string());
    let marker = tracker.get(0).unwrap();
     
    println!("{}", marker.identifier.data_id);
}

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

Determines if the Tracker has a valid Marker Chain, (a.k.a. not been tampered with).

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let mut mkrchn = Tracker::new("order~clothing~iStore~15150".to_string());
    mkrchn.add(1578071239, "notifier~billing~receipt~email".to_string(), "order~clothing~iStore~15150".to_string());

    assert!(Tracker::is_valid(&mkrchn));
}

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

Returns the length of the Tracker's Marker Chain.

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let mut tracker = Tracker::new("order~clothing~iStore~15150".to_string());
    tracker.add(1578071239, "notifier~billing~receipt~email".to_string(), "order~clothing~iStore~15150".to_string());
     
    // The Tracker has two Markers: the genesis Marker when new() was called, and the one that was added
    assert_eq!(tracker.len(), 2);
}

pub fn serialize(&self) -> String[src]

Serializes the Tracker's Marker Chain.

#Example

extern crate pbd;

use pbd::dtc::Tracker;

fn main() {
    let mut tracker = Tracker::new("order~clothing~iStore~15150".to_string());
    tracker.add(1578071239, "notifier~billing~receipt~email".to_string(), "order~clothing~iStore~15150".to_string());
     
    println!("{}", tracker.serialize());
}

Trait Implementations

impl Clone for Tracker[src]

impl Debug for Tracker[src]

impl<'de> Deserialize<'de> for Tracker[src]

impl Serialize 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> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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.

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

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

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,