yog_abi/api.rs
1//! The table passed to `yog_mod_register`.
2use super::{YogBus, YogGfxApi};
3
4/// Passed to `yog_mod_register`: the bus — everything a mod does goes
5/// through it (`docs/design/bus.md`) — and the one thing that can't afford
6/// a message, the frame's graphics.
7///
8/// When mods compiled against ABI `N` load on a runtime with ABI `M > N`:
9/// fields beyond `size` are not present in the mod's view — check `size` before
10/// accessing fields added in later minor versions.
11#[repr(C)]
12pub struct YogApi {
13 pub abi_version: u32,
14 /// `sizeof(YogApi)` at the runtime's build time.
15 pub size: u32,
16 /// The bus: calls, events and services by address (`docs/design/bus.md`).
17 /// Valid for the runtime's lifetime.
18 pub bus: *const YogBus,
19 /// The frame's graphics while a render event (`yog:event/client/render/…`)
20 /// runs on this thread; null otherwise. Valid until the event's handlers return.
21 pub gfx: unsafe extern "C" fn() -> *const YogGfxApi,
22}
23
24unsafe impl Send for YogApi {}
25unsafe impl Sync for YogApi {}