rlmesh::Model
A loaded model built from a Policy or predict closure. A shared handle: clones drive the same model, and the last one dropped closes it if close has not run.
struct ModelEvery corner and hook call on one model, across every run and serve on
it, runs one at a time, in submission order, on a library thread. A
corner or hook that calls back into its own model fails with the
RuntimeError class instead of deadlocking.
Associated functions
Methods
- spec()The resolved spec: the options' or the policy's.
- allow_fusion()Whether a grouped predict may fuse lanes across envs.
- native_chunk()The native chunk length, read after
load. - workflow_edition()The policy's workflow edition declaration.
- close()Release the model: stop every serve still running on it (drain), wait for queued calls, then fire the close hook, at most once.
- close_async()The async twin of
close. - serve()Serve the model on
addressuntil the server stops, then close it. - serve_async()The async twin of
serve: installs no signal handlers. - run()Drive this model against
envon the native runtime loop and return the result. - run_async()The async twin of
run: hooks run inside this future, where a blocking rlmesh call fails with theRuntimeErrorclass. - session()Bind this model to
envfor driving by hand. - session_async()The async twin of
session(nothing dials at creation, so it never waits).
describe
associated function[source]fn describe<P: Policy>() -> Result<Metadata>P’s metadata envelope. Reads P’s declarations only; nothing is
constructed or loaded.
new
associated function[source]fn new<P: Policy>(source: P, options: ModelOptions) -> Result<Model>Build a model from source, loading it now with an empty config. A
closure is a policy too (Model::new(|obs| Ok(..), ModelOptions::default())).
from_config
associated function[source]fn from_config<P: Policy + Default>(config: Kwargs) -> Result<Model>Build P::default() and load it with config.
spec
method[source]fn spec(&self) -> Option<&SpecArg>The resolved spec: the options’ or the policy’s.
allow_fusion
method[source]fn allow_fusion(&self) -> boolWhether a grouped predict may fuse lanes across envs.
native_chunk
method[source]fn native_chunk(&self) -> Option<u32>The native chunk length, read after load.
workflow_edition
method[source]fn workflow_edition(&self) -> Option<&str>The policy’s workflow edition declaration.
close
method[source]fn close(&self) -> Result<()>Release the model: stop every serve still running on it (drain),
wait for queued calls, then fire the close hook, at most once. Later
corner calls, runs and serves fail with the RuntimeError class.
close_async
method[source]async fn close_async(&self) -> Result<()>The async twin of close.
serve
method[source]fn serve(&self, address: &str, options: ModelServeOptions) -> Result<()>Serve the model on address until the server stops, then close it.
SIGINT stops it (drain, close) and fails with the cancellation class;
SIGTERM stops it and returns Ok.
serve_async
method[source]fn serve_async(
&self,
address: &str,
options: ModelServeOptions,
) -> impl std::future::Future<Output = Result<()>> + Send + 'staticThe async twin of serve: installs no signal
handlers. Dropping the future after its first poll stops the server;
the drain and the close finish on a library thread.
run
method[source]fn run<'e>(
&self,
env_or_address: impl Into<EnvTarget<'e>>, options: RunOptions<'_>,
) -> Result<RunResult>Drive this model against env on the native runtime loop and return
the result. The run borrows the model (it stays open) and the env
(closed only on close_env); hooks run on this thread. One run at a
time per model.
run_async
method[source]async fn run_async<'e>(
&self,
env_or_address: impl Into<EnvTarget<'e>>, options: RunOptions<'_>,
) -> Result<RunResult>The async twin of run: hooks run inside this future,
where a blocking rlmesh call fails with the RuntimeError class.
Dropping it cancels the run and fires no hook.
session
method[source]fn session<'a>(
&'a self, env_or_address: impl Into<EnvTarget<'a>>,
options: SessionOptions,
) -> Result<Session<'a>>Bind this model to env for driving by hand. Nothing dials until
first use; closing the session never closes the model.
session_async
method[source]async fn session_async<'a>(
&'a self, env_or_address: impl Into<EnvTarget<'a>>,
options: SessionOptions,
) -> Result<Session<'a>>The async twin of session (nothing dials at
creation, so it never waits).
Trait implementations
- impl<'a> From<&'a Model> for Describable<'a>
- impl Clone for Model
- impl Debug for Model
- impl<'a> From<&'a Model> for ModelTarget<'a>