Trait 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::Environment) -> &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::Environment) -> &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.

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§