#![no_std]
#![allow(non_camel_case_types)]
use core::ffi::c_void;
pub const LEVI_RS_ABI_VERSION: u32 = 2;
pub const LEVI_RS_MAIN_SYMBOL: &str = "levi_rs_main";
#[repr(C)]
#[derive(Clone, Copy)]
pub struct LeviRsStr {
pub ptr: *const u8,
pub len: usize,
}
pub type LeviRsModHandle = *mut c_void;
pub type LeviRsListenerHandle = *mut c_void;
pub type LeviRsTaskCb = unsafe extern "C" fn(user: *mut c_void);
pub type LeviRsStrSink = unsafe extern "C" fn(ctx: *mut c_void, s: LeviRsStr);
pub type LeviRsEventCb = unsafe extern "C" fn(
user: *mut c_void,
event_id: LeviRsStr,
snbt: LeviRsStr,
write_ctx: *mut c_void,
write_back: LeviRsStrSink,
);
pub type LeviRsCommandCb = unsafe extern "C" fn(
user: *mut c_void,
args: LeviRsStr,
origin_name: LeviRsStr,
out_ctx: *mut c_void,
out_success: LeviRsStrSink,
out_error: LeviRsStrSink,
);
pub type LeviRsCmdOutputSink =
unsafe extern "C" fn(ctx: *mut c_void, success: bool, output: LeviRsStr);
#[repr(C)]
pub struct LeviRsApi {
pub abi_version: u32,
pub struct_size: u32,
pub log: unsafe extern "C" fn(mod_: LeviRsModHandle, level: i32, msg: LeviRsStr),
pub gaming_status: unsafe extern "C" fn() -> i32,
pub schedule: unsafe extern "C" fn(cb: LeviRsTaskCb, user: *mut c_void),
pub schedule_after: unsafe extern "C" fn(cb: LeviRsTaskCb, user: *mut c_void, delay_ms: u64),
pub subscribe_event: unsafe extern "C" fn(
mod_: LeviRsModHandle,
event_id: LeviRsStr,
priority: i32,
cb: LeviRsEventCb,
user: *mut c_void,
) -> LeviRsListenerHandle,
pub unsubscribe_event:
unsafe extern "C" fn(mod_: LeviRsModHandle, listener: LeviRsListenerHandle) -> bool,
pub list_events: unsafe extern "C" fn(ctx: *mut c_void, sink: LeviRsStrSink),
pub execute_command:
unsafe extern "C" fn(cmd: LeviRsStr, ctx: *mut c_void, sink: LeviRsCmdOutputSink) -> bool,
pub register_command: unsafe extern "C" fn(
mod_: LeviRsModHandle,
name: LeviRsStr,
description: LeviRsStr,
permission: i32,
cb: LeviRsCommandCb,
user: *mut c_void,
) -> bool,
pub get_current_tick: unsafe extern "C" fn() -> u64,
pub get_tick_delta_time: unsafe extern "C" fn() -> f64,
pub get_player_count: unsafe extern "C" fn() -> i32,
pub get_sim_paused: unsafe extern "C" fn() -> bool,
}
#[repr(C)]
pub struct LeviRsModVTable {
pub abi_version: u32,
pub instance: *mut c_void,
pub on_enable: Option<unsafe extern "C" fn(instance: *mut c_void) -> bool>,
pub on_disable: Option<unsafe extern "C" fn(instance: *mut c_void) -> bool>,
pub on_unload: Option<unsafe extern "C" fn(instance: *mut c_void) -> bool>,
}
pub type LeviRsMainFn = unsafe extern "C" fn(
api: *const LeviRsApi,
self_: LeviRsModHandle,
out_vtable: *mut LeviRsModVTable,
) -> bool;