basically fully restored

This commit is contained in:
Sebastian Moser
2026-10-23 12:11:32 +02:00
parent 9078b108a6
commit 2b2d40148b
25 changed files with 879 additions and 37 deletions

View File

@@ -1,4 +1,5 @@
#![allow(warnings)]
#![feature(str_as_str)]
use std::cell::RefCell;
use std::fmt::format;
@@ -16,18 +17,22 @@ macro_rules! out {
}
pub fn write_to_mize_stdout(args: std::fmt::Arguments) -> MizeResult<()> {
println!("{}", format_args!(args));
println!("{}", args);
Ok(())
}
pub mod prelude {
pub use super::*;
pub use instance::Mize;
pub use id::*;
pub use error::MizeError;
pub use crate::mize_err;
pub use error::MizeResult;
pub use item::{Item, ItemData, IntoItemData};
pub use config::*;
pub use api::*;
pub use super::include_native;
pub use mize_macros::*;
}
pub use flume;
@@ -43,6 +48,7 @@ pub mod memstore;
pub mod proto;
pub mod types;
pub mod c_api;
pub mod api;
pub use async_trait::async_trait;
pub use ciborium;
@@ -57,10 +63,6 @@ use std::path::PathBuf;
use std::sync::{Arc, Mutex, OnceLock};
use crate::error::MizeResult;
use crate::instance::Mize;
use crate::mize_err;
/// Global Mize instance storage.
/// This is set once when the Mize instance is created and can be accessed from anywhere.
pub static GLOBAL_MIZE: OnceLock<Arc<Mutex<Mize>>> = OnceLock::new();
@@ -79,10 +81,10 @@ pub fn get_global_mize() -> MizeResult<Mize> {
/// Set the global Mize instance.
pub fn set_global_mize(mize: Mize) -> MizeResult<()> {
let arc = Arc::new(Mutex::new(mize));
let arc = Arc::new(Mutex::new(mize.clone()));
if let Err(_) = GLOBAL_MIZE.set(arc) {
let a = GLOBAL_MIZE.get().unwrap();
let mut b = a.lock();
let mut b = a.lock().map_err(|_| mize_err!("Failed to lock global Mize"))?;
*b = mize;
}
Ok(())
@@ -194,7 +196,7 @@ macro_rules! include_native {
$crate::config::opt($name)
$(
.method(stringify!($method), |args| {
let this = $crate::c_api::get_global_mize()?
let this = $crate::prelude::get_global_mize()?
.get_config($name)?
.native_mut::<$type_path>()?;
let result = this.$method();