pub trait Module {
// Required methods
fn name(&self) -> &str;
fn body(&self, g: &mut Graph);
// Provided methods
fn bootstrap(&self, _g: &mut Graph) { ... }
fn op(
&self,
g: &mut Graph,
bindings: &[(String, Output)],
) -> Vec<(String, String)> { ... }
fn call(&self) -> ModuleCall<'_, Self> { ... }
fn build(self) -> Result<ModelProto, BuildError>
where Self: Sized { ... }
}Expand description
Unit of composition. Implement name() + body(); framework
supplies op() and build(). Body declares inputs via
g.input("name") and emits via g.output("name", value) (local)
or g.net_out("name", peers, value) (network).
Required Methods§
Provided Methods§
Sourcefn bootstrap(&self, _g: &mut Graph)
fn bootstrap(&self, _g: &mut Graph)
Setup recording, run once before the first body poll. May
emit ContractResponse::Later; the engine drains every
outstanding bootstrap completion before activating body ops.
Sourcefn op(
&self,
g: &mut Graph,
bindings: &[(String, Output)],
) -> Vec<(String, String)>
fn op( &self, g: &mut Graph, bindings: &[(String, Output)], ) -> Vec<(String, String)>
Records body() into a function scope named self.name().
Emits a CALL in the outer target. Do not override.
Sourcefn call(&self) -> ModuleCall<'_, Self>
fn call(&self) -> ModuleCall<'_, Self>
Open a fluent call-site that inlines self’s body.
Sourcefn build(self) -> Result<ModelProto, BuildError>where
Self: Sized,
fn build(self) -> Result<ModelProto, BuildError>where
Self: Sized,
Emit one pre-compile ModelProto. Body becomes
functions[0] stamped with module_phase = "body". If
bootstrap recorded any ops it lands as a sibling
"<name>__bootstrap" stamped with "bootstrap".
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".