pub fn register<R: Rt, E: UserEvent>(
ctx: &mut ExecCtx<R, E>,
modules: BitFlags<Module>,
) -> Result<(ArcStr, ModuleResolver)>Expand description
Register selected modules of the standard graphix library
and return a root module that will load them along with a module resolver
that contains the necessary code. You need both of these for the rt
module.
Note, core is always included and registered, all the other modules are optional
ยงExample
use netidx::{publisher::Publisher, subscriber::Subscriber};
use anyhow::Result;
use poolshark::global::GPooled;
use graphix_compiler::ExecCtx;
use graphix_rt::{GXRt, GXConfigBuilder, GXHandle, GXEvent, NoExt};
use tokio::sync::mpsc;
use enumflags2::BitFlags;
async fn start_runtime(
publisher: Publisher,
subscriber: Subscriber,
sub: mpsc::Sender<GPooled<Vec<GXEvent>>>
) -> Result<GXHandle<NoExt>> {
let mut ctx = ExecCtx::new(GXRt::<NoExt>::new(publisher, subscriber))?;
let (root, mods) = graphix_stdlib::register(&mut ctx, BitFlags::all())?;
GXConfigBuilder::default()
.ctx(ctx)
.root(root)
.resolvers(vec![mods])
.sub(sub)
.build()?
.start()
.await
}