fmt, fixes and additions
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
use rhai::{Engine, Scope, EvalAltResult};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use rhai::{Engine, EvalAltResult, Scope};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
// Import the models and the registration function
|
||||
use heromodels::models::finance::account::Account;
|
||||
use heromodels::models::finance::asset::{Asset};
|
||||
use heromodels::models::finance::marketplace::{Listing};
|
||||
use heromodels::models::finance::asset::Asset;
|
||||
use heromodels::models::finance::marketplace::Listing;
|
||||
use heromodels::models::finance::rhai::register_rhai_engine_functions;
|
||||
|
||||
// Define a simple in-memory mock database for the example
|
||||
@@ -39,10 +39,10 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
// Register finance functions and types with the engine
|
||||
register_rhai_engine_functions(
|
||||
&mut engine,
|
||||
&mut engine,
|
||||
Arc::clone(&mock_db.accounts),
|
||||
Arc::clone(&mock_db.assets),
|
||||
Arc::clone(&mock_db.listings)
|
||||
Arc::clone(&mock_db.listings),
|
||||
);
|
||||
println!("Rhai functions registered.");
|
||||
|
||||
@@ -77,8 +77,13 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
println!("No accounts in mock DB.");
|
||||
}
|
||||
for (id, account) in final_accounts.iter() {
|
||||
println!("Account ID: {}, Name: '{}', User ID: {}, Assets: {}",
|
||||
id, account.name, account.user_id, account.assets.len());
|
||||
println!(
|
||||
"Account ID: {}, Name: '{}', User ID: {}, Assets: {}",
|
||||
id,
|
||||
account.name,
|
||||
account.user_id,
|
||||
account.assets.len()
|
||||
);
|
||||
}
|
||||
|
||||
// Print final state of Assets
|
||||
@@ -88,8 +93,10 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
println!("No assets in mock DB.");
|
||||
}
|
||||
for (id, asset) in final_assets.iter() {
|
||||
println!("Asset ID: {}, Name: '{}', Amount: {}, Type: {:?}",
|
||||
id, asset.name, asset.amount, asset.asset_type);
|
||||
println!(
|
||||
"Asset ID: {}, Name: '{}', Amount: {}, Type: {:?}",
|
||||
id, asset.name, asset.amount, asset.asset_type
|
||||
);
|
||||
}
|
||||
|
||||
// Print final state of Listings
|
||||
@@ -100,8 +107,13 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
}
|
||||
for (id, listing) in final_listings.iter() {
|
||||
println!(
|
||||
"Listing ID: {}, Title: '{}', Type: {:?}, Status: {:?}, Price: {}, Bids: {}",
|
||||
id, listing.title, listing.listing_type, listing.status, listing.price, listing.bids.len()
|
||||
"Listing ID: {}, Title: '{}', Type: {:?}, Status: {:?}, Price: {}, Bids: {}",
|
||||
id,
|
||||
listing.title,
|
||||
listing.listing_type,
|
||||
listing.status,
|
||||
listing.price,
|
||||
listing.bids.len()
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user