WIP: creation-sys-crate-ssv #69
@ -8,4 +8,5 @@ edition = "2021"
|
|||||||
bitvec = "1.0.1"
|
bitvec = "1.0.1"
|
||||||
deku = "0.17.0"
|
deku = "0.17.0"
|
||||||
libc = "0.2.155"
|
libc = "0.2.155"
|
||||||
|
num_enum = { version = "0.7.3", features = ["complex-expressions"] }
|
||||||
thiserror = "1.0.63"
|
thiserror = "1.0.63"
|
||||||
|
@ -1,13 +1,52 @@
|
|||||||
use thiserror::Error;
|
use deku::{deku_derive, DekuContainerRead, DekuError, DekuReader};
|
||||||
use std::{ffi::CString, fmt, path::Path, ptr};
|
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)]
|
#[derive(Error, Debug)]
|
||||||
pub struct SesamVitaleError {
|
pub struct SesamVitaleError {
|
||||||
code: u16,
|
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 {
|
impl fmt::Display for SesamVitaleError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "Got error code {} from SSV_LireConfig", self.code)
|
write!(f, "Got error code {} from SSV_LireConfig", self.code)
|
||||||
@ -63,4 +102,3 @@ pub fn read_config() -> Result<Configuration, SesamVitaleError> {
|
|||||||
|
|
||||||
Ok(configuration)
|
Ok(configuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod configuration;
|
pub mod configuration;
|
||||||
pub mod droits_vitale;
|
// pub mod droits_vitale;
|
||||||
|
Loading…
Reference in New Issue
Block a user