pub trait ParseableExt:
Extension
+ Clone
+ Eq
+ Ord
+ Debug
+ Display
+ Hash {
// Required methods
fn from_token_iter(
_tokens: &mut TokenIter<'_>,
) -> Result<Self, FromTokenIterError>;
fn evaluate(
&self,
stack: &mut Stack<'_>,
txenv: Option<&TxEnv<'_, '_>>,
) -> Result<bool, Error>;
fn push_to_builder(&self, builder: Builder) -> Builder;
fn satisfy<Pk, S>(&self, _sat: &S) -> Satisfaction
where Pk: ToPublicKey,
S: Satisfier<Pk>;
fn dissatisfy<Pk, S>(&self, _sat: &S) -> Satisfaction
where Pk: ToPublicKey,
S: Satisfier<Pk>;
}
Expand description
Support for parsing/serializing/satisfaction of extensions.
Extension
trait reasons about extension in abstract way whereas
this trait reasons about the concrete data structures.
Extension is similar to MiniscriptKey
, whereas ParseableExt is similar to
ToPublicKey
.
Required Methods§
Sourcefn from_token_iter(
_tokens: &mut TokenIter<'_>,
) -> Result<Self, FromTokenIterError>
fn from_token_iter( _tokens: &mut TokenIter<'_>, ) -> Result<Self, FromTokenIterError>
Parse the terminal from TokenIter
. Implementers of this trait are responsible
for making sure tokens is mutated correctly. If parsing is not successful, the tokens
should not be consumed.
Sourcefn evaluate(
&self,
stack: &mut Stack<'_>,
txenv: Option<&TxEnv<'_, '_>>,
) -> Result<bool, Error>
fn evaluate( &self, stack: &mut Stack<'_>, txenv: Option<&TxEnv<'_, '_>>, ) -> Result<bool, Error>
Interpreter support Evaluate the fragment based on inputs from stack. If an implementation of this is provided the user can use the interpreter API to parse scripts from blockchain and check which constraints are satisfied Output Ok(true) when the ext fragment is satisfied. Output Ok(false) when the ext fragment is dissatisfied, Output Some(Err) when there is an error in interpreter value.
Sourcefn push_to_builder(&self, builder: Builder) -> Builder
fn push_to_builder(&self, builder: Builder) -> Builder
Encoding of the current fragment
Sourcefn satisfy<Pk, S>(&self, _sat: &S) -> Satisfactionwhere
Pk: ToPublicKey,
S: Satisfier<Pk>,
fn satisfy<Pk, S>(&self, _sat: &S) -> Satisfactionwhere
Pk: ToPublicKey,
S: Satisfier<Pk>,
Produce a satisfaction for this from satisfier.
See satisfaction code in satisfy.rs for example
Note that the Satisfaction
struct also covers the case when
satisfaction is impossible/unavailable
Sourcefn dissatisfy<Pk, S>(&self, _sat: &S) -> Satisfactionwhere
Pk: ToPublicKey,
S: Satisfier<Pk>,
fn dissatisfy<Pk, S>(&self, _sat: &S) -> Satisfactionwhere
Pk: ToPublicKey,
S: Satisfier<Pk>,
Produce a satisfaction for this from satisfier.
See satisfaction code in satisfy.rs for example
Note that the Satisfaction
struct also covers the case when
dissatisfaction is impossible/unavailable
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.