fixup! feat: Gestion des versions multiples de FSV dans le wrapper exposant les fonctions de la librairie
This commit is contained in:
parent
7992f3df0e
commit
c9b1895e0c
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum SUPPORTED_FSV_VERSIONS {
|
pub enum SUPPORTED_FSV_VERSIONS {
|
||||||
V1_40_14, // 1.40.14
|
V1_40_14, // 1.40.14
|
||||||
V1_40_13, // 1.40.13
|
V1_40_13, // 1.40.13
|
||||||
@ -19,11 +19,11 @@ impl SUPPORTED_FSV_VERSIONS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod BINDINGS_V1_40_14 {
|
mod BINDINGS_V1_40_14 {
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings_1.40.14.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings_1.40.14.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod BINDINGS_V1_40_13 {
|
mod BINDINGS_V1_40_13 {
|
||||||
include!(concat!(env!("OUT_DIR"), "/bindings_1.40.13.rs"));
|
include!(concat!(env!("OUT_DIR"), "/bindings_1.40.13.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,14 +137,14 @@ impl SSVLibrary<V1_40_13> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_library_path(version: SUPPORTED_FSV_VERSIONS) -> String {
|
pub fn get_library_path(version: &SUPPORTED_FSV_VERSIONS) -> String {
|
||||||
let root_path = get_library_root_path();
|
let root_path = get_library_root_path();
|
||||||
let library_name = get_library_name();
|
let library_name = get_library_name();
|
||||||
let version = version.as_str();
|
let version = version.as_str();
|
||||||
format!("{root_path}/{version}/lib/{library_name}")
|
format!("{root_path}/{version}/lib/{library_name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sesam_ini_path(version: SUPPORTED_FSV_VERSIONS) -> String {
|
pub fn sesam_ini_path(version: &SUPPORTED_FSV_VERSIONS) -> String {
|
||||||
let root_path = get_sesam_ini_root_path();
|
let root_path = get_sesam_ini_root_path();
|
||||||
let version = version.as_str();
|
let version = version.as_str();
|
||||||
format!("{root_path}/{version}/conf/sesam.ini")
|
format!("{root_path}/{version}/conf/sesam.ini")
|
||||||
@ -171,22 +171,22 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_initlib2() {
|
fn test_initlib2() {
|
||||||
let lib_path = &get_library_path(SUPPORTED_FSV_VERSIONS::V1_40_13);
|
let lib_path = &get_library_path(&SUPPORTED_FSV_VERSIONS::V1_40_13);
|
||||||
let ssv_library = SSVLibrary::<V1_40_13>::new(lib_path).expect("SSVLibrary::new failed");
|
let ssv_library = SSVLibrary::<V1_40_13>::new(lib_path).expect("SSVLibrary::new failed");
|
||||||
|
|
||||||
let sesam_ini_str =
|
let sesam_ini_str =
|
||||||
CString::new(sesam_ini_path(SUPPORTED_FSV_VERSIONS::V1_40_13)).expect("CString::new failed");
|
CString::new(sesam_ini_path(&SUPPORTED_FSV_VERSIONS::V1_40_13)).expect("CString::new failed");
|
||||||
let result = unsafe { ssv_library.ssv_init_lib2(sesam_ini_str.as_ptr()) }.unwrap();
|
let result = unsafe { ssv_library.ssv_init_lib2(sesam_ini_str.as_ptr()) }.unwrap();
|
||||||
assert_eq!(result, 0);
|
assert_eq!(result, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_lire_config_and_carte_ps() {
|
fn test_lire_config_and_carte_ps() {
|
||||||
let lib_path = &get_library_path(SUPPORTED_FSV_VERSIONS::V1_40_13);
|
let lib_path = &get_library_path(&SUPPORTED_FSV_VERSIONS::V1_40_13);
|
||||||
let ssv_library = SSVLibrary::<V1_40_13>::new(lib_path).expect("SSVLibrary::new failed");
|
let ssv_library = SSVLibrary::<V1_40_13>::new(lib_path).expect("SSVLibrary::new failed");
|
||||||
|
|
||||||
let sesam_ini_str =
|
let sesam_ini_str =
|
||||||
CString::new(sesam_ini_path(SUPPORTED_FSV_VERSIONS::V1_40_13)).expect("CString::new failed");
|
CString::new(sesam_ini_path(&SUPPORTED_FSV_VERSIONS::V1_40_13)).expect("CString::new failed");
|
||||||
let result = unsafe { ssv_library.ssv_init_lib2(sesam_ini_str.as_ptr()) }.unwrap();
|
let result = unsafe { ssv_library.ssv_init_lib2(sesam_ini_str.as_ptr()) }.unwrap();
|
||||||
assert_eq!(result, 0);
|
assert_eq!(result, 0);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user