pub trait Package<X: GXExt> {
// Required methods
fn register(
ctx: &mut ExecCtx<GXRt<X>, X::UserEvent>,
modules: &mut FxHashMap<Path, ArcStr>,
root_mods: &mut IndexSet<ArcStr>,
) -> Result<()>;
fn is_custom(gx: &GXHandle<X>, env: &Env, e: &CompExp<X>) -> bool;
async fn init_custom(
gx: &GXHandle<X>,
env: &Env,
stop: Sender<()>,
e: CompExp<X>,
run_on_main: MainThreadHandle,
) -> Result<Box<dyn CustomDisplay<X>>>;
fn main_program() -> Option<&'static str>;
}Expand description
Trait implemented by Graphix packages
Required Methods§
Sourcefn register(
ctx: &mut ExecCtx<GXRt<X>, X::UserEvent>,
modules: &mut FxHashMap<Path, ArcStr>,
root_mods: &mut IndexSet<ArcStr>,
) -> Result<()>
fn register( ctx: &mut ExecCtx<GXRt<X>, X::UserEvent>, modules: &mut FxHashMap<Path, ArcStr>, root_mods: &mut IndexSet<ArcStr>, ) -> Result<()>
register builtins and return a resolver containing Graphix code contained in the package.
Graphix modules must be registered by path in the modules table and the package must be registered by name in the root_mods set. Normally this is handled by the defpackage macro.
Sourcefn is_custom(gx: &GXHandle<X>, env: &Env, e: &CompExp<X>) -> bool
fn is_custom(gx: &GXHandle<X>, env: &Env, e: &CompExp<X>) -> bool
Return true if the CompExp matches the custom display type
of this package.
Sourceasync fn init_custom(
gx: &GXHandle<X>,
env: &Env,
stop: Sender<()>,
e: CompExp<X>,
run_on_main: MainThreadHandle,
) -> Result<Box<dyn CustomDisplay<X>>>
async fn init_custom( gx: &GXHandle<X>, env: &Env, stop: Sender<()>, e: CompExp<X>, run_on_main: MainThreadHandle, ) -> Result<Box<dyn CustomDisplay<X>>>
Build and return a CustomDisplay instance which will be used
to display the CompExp e.
If the custom display mode wishes to stop (for example the
user closed the last gui window), then the stop channel should
be triggered, and the shell will call CustomDisplay::clear
before dropping the CustomDisplay.
main_thread_rx is Some if this package declared
MAIN_THREAD and the shell has a main-thread channel
available. The custom display should hold onto it and return
it from clear().
Sourcefn main_program() -> Option<&'static str>
fn main_program() -> Option<&'static str>
Return the main program source if this package has one and the
standalone feature is enabled.
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.