usc 1.20230730.1349

A common lib for unitedservices
Documentation
pub mod const_type_defaults;
pub mod i_mysql_db_model;
pub mod my_mysql;
pub mod i_db_model;
pub mod query_keys;
pub use i_mysql_db_model::*;
pub use const_type_defaults::*;
pub use my_mysql::*;
pub use i_db_model::*;
pub use query_keys::*;

use futures::lock::Mutex;
use serde_json::{json, Value as JSONValue};
use lazy_static::lazy_static;
use std::sync::Arc;
use crate::mylog;
use sqlx::Value;
use crate::myerror::MyError;

lazy_static! {
pub   static  ref EXTRA_OPTIONS: Mutex<JSONValue> = Mutex::new(json!({}));
}




pub async fn extra_options_set_string(path:&str, value:&str) ->Result<(),MyError>{
    //mylog!("extra_options_set_string start");
    let mut options=&mut *EXTRA_OPTIONS.lock().await;
    crate::myjson::myjson_set_string(options,path,value)?;
    Ok(())
}

pub async fn extra_options_get_string(path:&str,default_value:&str)->String{
    //mylog!("extra_options_get_string start");

    let result=crate::myjson::myjson_get_string(&*EXTRA_OPTIONS.lock().await,path,default_value);
    //mylog!("extra_options_get_string end");
    result
}


pub async fn extra_options_get(path:&str,default_value:JSONValue)->JSONValue{
   // mylog!("extra_options_get start");

    let result=crate::myjson::myjson_get(&*EXTRA_OPTIONS.lock().await,path,default_value);
    //mylog!("extra_options_get end");
    result
}

pub async fn extra_options_set(path:&str,value:& JSONValue)->Result<(),MyError>{
    //mylog!("extra_options_set start");
    let mut options=&mut *EXTRA_OPTIONS.lock().await;
    crate::myjson::myjson_set(options,path,value)?;
    let result=crate::myjson::myjson_set(options,path,value);
   // mylog!("extra_options_set end");
    result
}


pub async fn extra_options_append_value(path:&str, value:&JSONValue) ->Result<(),MyError>{
    mylog!("extra_options_append_value start");
    let mut options=&mut *EXTRA_OPTIONS.lock().await;
    crate::myok!(crate::myjson::myjson_append_to_vec(options,path,value),??);
    mylog!("extra_options_append_value end");
    Ok(())
}