ppc login works in mme main

This commit is contained in:
Sebastian Moser
2026-11-01 14:49:38 +01:00
parent 66b8713e3a
commit 6eedb1826a
68 changed files with 4123 additions and 1467 deletions

View File

@@ -1,8 +1,9 @@
use crate::{config, get_global_mize};
use crate::config::{ConfigOpt, FromItemData, MizeFun};
use ciborium::into_writer;
use ciborium::from_reader;
use colored::Colorize;
use serde_json::from_reader;
use serde::de::DeserializeOwned;
use core::fmt;
use serde::Deserialize;
use serde::Serialize;
@@ -13,7 +14,8 @@ use std::sync::MutexGuard;
use std::{boxed, io};
use std::fmt::Display;
use std::i128;
use tracing::{debug, instrument, trace, warn};
use crate::tracing::instrument;
use crate::prelude::*;
use crate::error::{IntoMizeResult, MizeError, MizeErrorWhichImplementsError, MizeResult};
use crate::id::MizeId;
@@ -256,7 +258,12 @@ impl ItemData {
let fun_num = self.get_path("_fun_num")?.value_u32()?;
let fun_id = mize.clone().id_new_dots("mize.fun")?.join(format!("{fun_num}").as_str())?;
let fun = fun_values.remove(&fun_id).ok_or(mize_err!("fun with id {fun_id} not in fun_values"))?;
drop(fun_values);
let res = fun(args)?;
let mut fun_values = mize.fun_values.lock()?;
fun_values.insert(fun_id, fun);
return Ok(res);
}
@@ -406,6 +413,13 @@ impl ItemData {
return None;
}
pub fn deserialize<T: Serialize + DeserializeOwned>(&self) -> MizeResult<T> {
let mut buffer = Vec::new();
into_writer(&self, &mut buffer)?;
let cbor_val: T = from_reader(buffer.as_slice())?;
Ok(cbor_val)
}
/// Get an immutable reference to the native value stored in this ItemData.
///
/// If the ItemData has a `_native` field (stored via `from_native()`), returns a guard
@@ -467,6 +481,7 @@ impl ItemData {
///
/// Otherwise, constructs the value via `T::from_itemdata(self)`, stores it in the
/// registry, and returns a guard to it.
/// i hate rust. (as you can't have a generic FromItemData impl and then more specific ones.)
pub fn native_from<T: FromItemData + Any + Send + Sync + 'static>(&self) -> MizeResult<NativeRefGuard<T>> {
// Fast path: the registry already holds a T for this ItemData
if let Some(id) = self.try_get_native_id() {