Skip to main content

ReceiptStore

Struct ReceiptStore 

Source
pub struct ReceiptStore { /* private fields */ }
Expand description

Storage and verification of ExperimentReceipts.

Each receipt is serialised to JSON on insertion so that the raw bytes remain stable. Verification deserialises and recomputes the binding digest.

Implementations§

Source§

impl ReceiptStore

Source

pub fn new() -> Self

Create an empty receipt store.

Source

pub fn insert(&mut self, receipt: &ExperimentReceipt) -> Result<(), String>

Insert a receipt, overwriting any existing entry for the same id.

§Errors

Returns an error string if serialisation fails (practically infallible for well-formed receipts).

Source

pub fn len(&self) -> usize

Number of stored receipts.

Source

pub fn is_empty(&self) -> bool

Returns true when no receipts are stored.

Source

pub fn verify(&self, id: &str) -> bool

Verify the receipt identified by id.

Returns true if the receipt passes verify_receipt. Returns false if the id is unknown, deserialisation fails, or verification fails (tampered fields).

Source

pub fn verify_all(&self) -> HashMap<String, bool>

Verify every stored receipt.

Returns a map from experiment id to verification outcome.

Source

pub fn get_json(&self, id: &str) -> Option<&str>

Retrieve the stored JSON string for an experiment id.

Source

pub fn get(&self, id: &str) -> Option<ExperimentReceipt>

Retrieve and deserialise a receipt by experiment id.

Returns None if the id is unknown or deserialisation fails.

Trait Implementations§

Source§

impl Debug for ReceiptStore

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ReceiptStore

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.