|
|
|
@ -1,13 +1,52 @@
|
|
|
|
|
use thiserror::Error;
|
|
|
|
|
use deku::{deku_derive, DekuContainerRead, DekuError, DekuReader};
|
|
|
|
|
use std::{ffi::CString, fmt, path::Path, ptr};
|
|
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
|
|
use crate::{bindings::{SSV_InitLIB2, SSV_TermLIB}, types::{common::read_from_buffer, configuration::Configuration}};
|
|
|
|
|
use crate::{
|
|
|
|
|
bindings::{SSV_InitLIB2, SSV_LireConfig, SSV_TermLIB},
|
|
|
|
|
types::{common::read_from_buffer, configuration::Configuration},
|
|
|
|
|
};
|
|
|
|
|
use num_enum::FromPrimitive;
|
|
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
|
pub struct SesamVitaleError {
|
|
|
|
|
code: u16,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Eq, PartialEq, FromPrimitive)]
|
|
|
|
|
#[repr(u16)]
|
|
|
|
|
enum SSVIntError {
|
|
|
|
|
CPSNotInserted = 61441,
|
|
|
|
|
|
|
|
|
|
#[num_enum(catch_all)]
|
|
|
|
|
NotImplemented(u16),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_sesam_vitale_error() {
|
|
|
|
|
let int_error = SSVIntError::from(61441);
|
|
|
|
|
assert_eq!(int_error, SSVIntError::CPSNotInserted);
|
|
|
|
|
|
|
|
|
|
let int_error = SSVIntError::from(123);
|
|
|
|
|
assert_eq!(int_error, SSVIntError::NotImplemented(123));
|
|
|
|
|
println!("{:?}", int_error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Error, Debug)]
|
|
|
|
|
enum SSVError {
|
|
|
|
|
#[error("Erreur standard de la librairie SSV")]
|
|
|
|
|
SSVStandard,
|
|
|
|
|
// #[error("Erreur de parsing")]
|
|
|
|
|
// Parsing(#[from] ParsingError),
|
|
|
|
|
#[error("Erreur inattendue de la librairie SSV (TMP)")]
|
|
|
|
|
SSVUnknownTmp,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl fmt::Display for SesamVitaleError {
|
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
|
write!(f, "Got error code {} from SSV_LireConfig", self.code)
|
|
|
|
@ -63,4 +102,3 @@ pub fn read_config() -> Result<Configuration, SesamVitaleError> {
|
|
|
|
|
|
|
|
|
|
Ok(configuration)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|