Struct sapio::template::builder::Builder[][src]

pub struct Builder { /* fields omitted */ }

Builder can be used to interactively put together a transaction template before finalizing into a Template.

Implementations

impl Builder[src]

pub fn new(ctx: Context) -> Builder[src]

Creates a new transaction template with 1 input and no outputs.

pub fn ctx(&self) -> &Context[src]

get a read-only reference to the builder’s context

pub fn spend_amount(self, amount: Amount) -> Result<Self, CompilationError>[src]

reduce the amount availble in the builder’s context

pub fn add_output<T: Compilable>(
    self,
    amount: Amount,
    contract: &T,
    metadata: Option<OutputMeta>
) -> Result<Self, CompilationError>
[src]

Creates a new Output, forcing the compilation of the compilable object and defaulting metadata if not provided to blank.

pub fn add_amount(self, a: Amount) -> Self[src]

adds available funds to the builder’s context object. TODO: Make guarantee there is some external input?

pub fn add_sequence(self) -> Self[src]

Adds another output. Follow with a call to set_sequence(-1, …) to fill in the back.

pub fn set_sequence(
    self,
    ii: isize,
    s: AnyRelTimeLock
) -> Result<Self, CompilationError>
[src]

set_sequence adds a height or time based relative lock time to the template. If a lock time is already set, it will check if it is of the same kind. Differing kinds will throw an error. Otherwise, it will merge by taking the max of the argument.

Negative indexing allows us to work from the back element easily

pub fn set_lock_time(
    self,
    lt_in: AnyAbsTimeLock
) -> Result<Self, CompilationError>
[src]

set_lock_time adds a height or time based absolute lock time to the template. If a lock time is already set, it will check if it is of the same kind. Differing kinds will throw an error. Otherwise, it will merge by taking the max of the argument.

pub fn set_label(self, label: String) -> Self[src]

overwrite any existing label with the provided string, or set a label if non provided thus far.

pub fn get_tx(&self) -> Transaction[src]

Creates a transaction from a Builder. Generally, should not be called directly.

Trait Implementations

impl From<Builder> for Template[src]

impl From<Builder> for TxTmplIt[src]

Auto Trait Implementations

impl !RefUnwindSafe for Builder

impl Send for Builder

impl Sync for Builder

impl Unpin for Builder

impl !UnwindSafe for Builder

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.