feat: initialize a utils lib with config functions handling config files in local and standard OS directories

This commit is contained in:
2024-08-22 20:40:12 +02:00
parent 90ff593438
commit f56439c9c5
11 changed files with 102 additions and 9 deletions

View File

@ -1,16 +1,16 @@
/// High level API for the SSV library,
/// based on the low level bindings in libssv.rs.
extern crate dotenv;
use libc::{c_void, size_t};
use std::env;
use std::ffi::CString;
use std::path::PathBuf;
use std::ptr;
use thiserror::Error;
use crate::cps::lire_carte;
use crate::libssv::{SSV_InitLIB2, SSV_LireConfig};
use ::utils::config::load_config;
#[derive(Error, Debug)]
pub enum SSVDemoError {
#[error(transparent)]
@ -66,12 +66,11 @@ fn ssv_lire_config() -> Result<(), SSVDemoError> {
pub fn demo() -> Result<(), SSVDemoError> {
// TODO : this is probably not working on release, because I'm not sure it exists a CARGO_MANIFEST_DIR and so it can find the `.env`
// Maybe we could use a system standard config path to store a config file
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR must be set");
let manifest_path = PathBuf::from(manifest_dir);
dotenv::from_path(manifest_path.join(".env")).ok();
println!("------- Demo for the SSV library --------");
load_config()?;
ssv_init_lib_2()?;
let code_pin = "1234";