nexus/lib.rs
1//! Bindings for Raidcore Nexus addons.
2//!
3//! # Usage
4//! ```no_run
5//! # mod main {
6//! use nexus::{
7//! gui::{register_render, render, RenderType},
8//! imgui::Window
9//! };
10//!
11//! nexus::export! {
12//! name: "My Addon",
13//! signature: -0x12345678,
14//! load: || {
15//! register_render(RenderType::Render, render!(|ui| {
16//! Window::new("My Window").build(ui, || {
17//! ui.text("Hello World");
18//! });
19//! }));
20//! }
21//! }
22//! # }
23//! ```
24
25pub mod addon;
26mod api;
27mod globals;
28mod revertible;
29mod util;
30
31#[cfg(feature = "panic")]
32mod panic;
33
34#[cfg(feature = "log")]
35mod logger;
36
37pub use self::{
38 addon::{AddonFlags, AddonLoad, AddonUnload, UpdateProvider},
39 api::*,
40 globals::{on_unload, with_ui},
41 revertible::Revertible,
42};
43pub use imgui;
44pub use nexus_codegen::export;
45
46/// Returns the Nexus [`AddonApi`] instance.
47///
48/// Panics if called before initialization.
49#[inline]
50#[deprecated = "use AddonApi::get() instead"]
51pub fn addon_api() -> &'static AddonApi {
52 AddonApi::get()
53}
54
55/// Fields supported by the [`export`] macro.
56pub struct SupportedFields {
57 /// Raidcore addon id or random unique negative integer, if not on Raidcore.
58 pub signature: i32,
59
60 /// Name of the addon. Defaults to `CARGO_PKG_NAME`.
61 pub name: Option<String>,
62
63 /// Load function of the addon.
64 pub load: Option<AddonLoad>,
65
66 /// Unload function of the addon.
67 pub unload: Option<AddonUnload>,
68
69 /// Information about the addon.
70 pub flags: Option<AddonFlags>,
71
72 /// What platform the addon is hosted on.
73 pub provider: Option<UpdateProvider>,
74
75 /// Link to the update resource.
76 pub update_link: Option<&'static str>,
77
78 #[cfg(feature = "log")]
79 /// Filter for the log. Same syntax as [env_logger](https://docs.rs/env_logger/latest/env_logger/#enabling-logging).
80 pub log_filter: Option<&'static str>,
81}
82
83#[doc(hidden)]
84pub mod __macro {
85 pub use crate::{
86 globals::{deinit, init, with_ui},
87 util::str_from_c,
88 };
89}