improve and add models

This commit is contained in:
timurgordon
2025-06-12 05:22:17 +03:00
parent c3f6b91aa0
commit 00c4e6a1eb
19 changed files with 1520 additions and 42 deletions

View File

@@ -2,7 +2,7 @@ use rhai::plugin::*;
use rhai::{Engine, EvalAltResult, Position, Module, INT, Dynamic, Array};
use std::sync::Arc;
use std::mem;
use chrono::{DateTime, Utc};
use chrono::Utc;
use super::account::Account;
use super::asset::{Asset, AssetType};
@@ -10,7 +10,6 @@ use super::marketplace::{Listing, Bid, ListingStatus, ListingType, BidStatus};
use crate::db::hero::OurDB;
use crate::db::{Collection, Db};
use heromodels_core::Model;
type RhaiAccount = Account;
type RhaiAsset = Asset;
@@ -689,18 +688,8 @@ mod bid_module {
Ok(bid.clone())
}
}
use std::collections::HashMap;
use std::sync::Mutex;
use rhai::ImmutableString;
// Custom error type for Rhai
struct RhaiStringError(String);
impl std::fmt::Debug for RhaiStringError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}
// Register all Rhai functions for the finance module
pub fn register_finance_rhai_module(engine: &mut Engine, db: Arc<OurDB>) {
// --- Register model-specific modules with the engine ---