Skip to main content

TranscriptBuilder

Struct TranscriptBuilder 

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

The TranscriptBuilder struct is responsible for constructing a transcript of input data. It contains a domain for unique identification, a data vector to hold the input data, and an optional prefix for new labels.

§Examples

use ink_quill::TranscriptBuilder;
let mut builder = TranscriptBuilder::empty("example domain");
builder = builder.with("label", &123u64);
let result = builder.compile();

§Panics

Methods of this struct may panic if called with a duplicated label. To avoid this, ensure labels are unique and do not repeat.

§Notes

  • The domain field is not just for descriptive purposes. It’s used as a key in the Blake3 hashing function, so changing it will result in different hashes for the same input data.
  • Methods of this struct may panic if called with a duplicated label. To avoid this, ensure labels are unique and do not repeat.

Implementations§

Source§

impl TranscriptBuilder

Source

pub fn empty(domain: impl Into<String>) -> Self

Source

pub fn get_domain(&self) -> &str

Source

pub fn merge(self, other: Self) -> Self

Merges another TranscriptBuilder instance into the current one. The function mutates the current instance, extending its data with the data from the other instance. The function consumes the other instance and returns the current instance.

Source

pub fn with_prefix(self, prefix: String) -> Self

Set a prefix for the new values passed to the transcript builder, this can be used when you want to use the transcript builder in a loop.

Source

pub fn with<T: TranscriptBuilderInput>( self, label: &'static str, data: &T, ) -> Self

Provide the builder with the given input and label, the label MUST be unique. The ordering of the data does not matter.

Source

pub fn compile(&self) -> Vec<u8> ⓘ

Returns a combined input stream from all the inputs this builder has already been given.

Source

pub fn hash(&self) -> [u8; 32]

Returns the hash of the value using the default blake3 hasher.

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.