Layer

Trait Layer 

Source
pub trait Layer {
    type Solution;

    // Required methods
    fn parse_puzzle(
        allocator: &Allocator,
        puzzle: Puzzle,
    ) -> Result<Option<Self>, DriverError>
       where Self: Sized;
    fn parse_solution(
        allocator: &Allocator,
        solution: NodePtr,
    ) -> Result<Self::Solution, DriverError>;
    fn construct_puzzle(
        &self,
        ctx: &mut SpendContext,
    ) -> Result<NodePtr, DriverError>;
    fn construct_solution(
        &self,
        ctx: &mut SpendContext,
        solution: Self::Solution,
    ) -> Result<NodePtr, DriverError>;

    // Provided methods
    fn construct_spend(
        &self,
        ctx: &mut SpendContext,
        solution: Self::Solution,
    ) -> Result<Spend, DriverError> { ... }
    fn construct_coin_spend(
        &self,
        ctx: &mut SpendContext,
        coin: Coin,
        solution: Self::Solution,
    ) -> Result<CoinSpend, DriverError> { ... }
}
Expand description

An individual layer in a puzzle’s hierarchy.

Required Associated Types§

Source

type Solution

Most of the time, this is an actual CLVM type representing the solution. However, you can also use a helper struct and customize Layer::construct_solution and Layer::parse_solution.

Required Methods§

Source

fn parse_puzzle( allocator: &Allocator, puzzle: Puzzle, ) -> Result<Option<Self>, DriverError>
where Self: Sized,

Parses this layer from the given puzzle, returning None if the puzzle doesn’t match. An error is returned if the puzzle should have matched but couldn’t be parsed.

Source

fn parse_solution( allocator: &Allocator, solution: NodePtr, ) -> Result<Self::Solution, DriverError>

Parses the Layer::Solution type from a CLVM solution pointer.

Source

fn construct_puzzle( &self, ctx: &mut SpendContext, ) -> Result<NodePtr, DriverError>

Constructs the full curried puzzle for this layer. Ideally, the puzzle itself should be cached in the SpendContext.

Source

fn construct_solution( &self, ctx: &mut SpendContext, solution: Self::Solution, ) -> Result<NodePtr, DriverError>

Constructs the full solution for this layer. Can be used to construct the solution from a helper struct, if it’s not directly a CLVM type. It’s also possible to influence the solution based on the puzzle, if needed.

Provided Methods§

Source

fn construct_spend( &self, ctx: &mut SpendContext, solution: Self::Solution, ) -> Result<Spend, DriverError>

Creates a spend for this layer.

Source

fn construct_coin_spend( &self, ctx: &mut SpendContext, coin: Coin, solution: Self::Solution, ) -> Result<CoinSpend, DriverError>

Creates a coin spend for this layer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Layer for Puzzle

Source§

impl Layer for DelegationLayer

Source§

impl Layer for MOfNLayer

Source§

impl Layer for OracleLayer

Source§

impl Layer for P2CurriedLayer

Source§

impl Layer for P2DelegatedBySingletonLayer

Source§

impl Layer for P2DelegatedConditionsLayer

Source§

impl Layer for P2OneOfManyLayer

Source§

impl Layer for P2ParentLayer

Source§

impl Layer for P2SingletonLayer

Source§

impl Layer for RevocationLayer

Source§

impl Layer for RoyaltyTransferLayer

Source§

impl Layer for SettlementLayer

Source§

impl Layer for StandardLayer

Source§

impl Layer for StateSchedulerLayer

Source§

impl Layer for StreamLayer

Source§

impl Layer for VerificationLayer

Source§

impl<I> Layer for BulletinLayer<I>
where I: Layer,

Source§

impl<I> Layer for CatLayer<I>
where I: Layer,

Source§

impl<I> Layer for OptionContractLayer<I>

Source§

impl<I> Layer for SingletonLayer<I>
where I: Layer,

Source§

impl<I> Layer for WriterLayer<I>
where I: Layer,

Source§

impl<M, I> Layer for DidLayer<M, I>

Source§

impl<M, I> Layer for NftStateLayer<M, I>

Source§

impl<S, P> Layer for ActionLayer<S, P>

Source§

impl<T> Layer for ConditionsLayer<T>

Source§

impl<T> Layer for T

Source§

impl<T, I> Layer for AugmentedConditionLayer<T, I>

Source§

impl<T, I> Layer for NftOwnershipLayer<T, I>
where T: Layer, I: Layer,

Source§

impl<V> Layer for PrecommitLayer<V>