Trait simplicity::jet::Jet

source ·
pub trait Jet: Copy + Eq + Ord + Hash + Debug + Display + FromStr + 'static {
    type Environment;
    type CJetEnvironment;

    // Required methods
    fn cmr(&self) -> Cmr;
    fn source_ty(&self) -> TypeName;
    fn target_ty(&self) -> TypeName;
    fn encode<W: Write>(&self, w: &mut BitWriter<W>) -> Result<usize>;
    fn decode<I: Iterator<Item = u8>>(
        bits: &mut BitIter<I>
    ) -> Result<Self, Error>;
    fn c_jet_env<'env>(
        &self,
        env: &'env Self::Environment
    ) -> &'env Self::CJetEnvironment;
    fn c_jet_ptr(
        &self
    ) -> &dyn Fn(&mut CFrameItem, CFrameItem, &Self::CJetEnvironment) -> bool;
    fn cost(&self) -> Cost;
}
Expand description

Family of jets that share an encoding scheme and execution environment.

Jets are single nodes that read an input, process it internally using foreign C code (black box), and produce an output. Jets may read values from their environment.

Jets are always leaves in a Simplicity DAG.

Required Associated Types§

source

type Environment

Environment for jet to read from

source

type CJetEnvironment

CJetEnvironment to interact with C FFI.

Required Methods§

source

fn cmr(&self) -> Cmr

Return the CMR of the jet.

source

fn source_ty(&self) -> TypeName

Return the source type of the jet.

source

fn target_ty(&self) -> TypeName

Return the target type of the jet.

source

fn encode<W: Write>(&self, w: &mut BitWriter<W>) -> Result<usize>

Encode the jet to bits.

source

fn decode<I: Iterator<Item = u8>>(bits: &mut BitIter<I>) -> Result<Self, Error>

Decode a jet from bits.

source

fn c_jet_env<'env>( &self, env: &'env Self::Environment ) -> &'env Self::CJetEnvironment

Obtains a C FFI compatible environment for the jet.

source

fn c_jet_ptr( &self ) -> &dyn Fn(&mut CFrameItem, CFrameItem, &Self::CJetEnvironment) -> bool

Obtain the FFI C pointer for the jet.

source

fn cost(&self) -> Cost

Return the cost of the jet.

Object Safety§

This trait is not object safe.

Implementors§