feat: Une enums for deserializable fields in CPS Holder group (01)
This commit is contained in:
parent
0fd14762f4
commit
f55ac6f7df
@ -20,13 +20,22 @@ pub mod group_1_holder {
|
||||
card_type_raw: NumericString,
|
||||
#[deku(ctx = "extract_enum_id_from_str::<u8>(&*card_type_raw.0, 255)")]
|
||||
pub card_type: CardPSType,
|
||||
#[deku(temp)]
|
||||
national_id_type_raw: NumericString,
|
||||
#[deku(ctx = "extract_enum_id_from_str::<u8>(&*national_id_type_raw.0, 255)")]
|
||||
pub national_id_type: NationalIDType,
|
||||
// TODO: handle national_id depending on national_id_type
|
||||
pub national_id: AlphaNumericString, // /!\ CE and not CA
|
||||
pub national_id_key: AlphaNumericString,
|
||||
#[deku(temp)]
|
||||
civility_code_raw: NumericString,
|
||||
#[deku(ctx = "extract_enum_id_from_str::<u8>(&*civility_code_raw.0, 255)")]
|
||||
pub civility_code: CivilityCode,
|
||||
pub holder_lastname: AlphaNumericString, // /!\ CE and not CA
|
||||
pub holder_firstname: AlphaNumericString, // /!\ CE and not CA
|
||||
pub category_card: AlphaNumericString,
|
||||
#[deku(temp)]
|
||||
category_card_size: u8,
|
||||
pub category_card: CategoryCard,
|
||||
}
|
||||
|
||||
// Fields
|
||||
@ -48,19 +57,133 @@ pub mod group_1_holder {
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct NationalIDType(pub NumericString);
|
||||
#[deku(ctx = "id: u8", id = "id")]
|
||||
pub enum NationalIDType {
|
||||
#[deku(id = 0)]
|
||||
ADELI, // N° ADELI
|
||||
#[deku(id = 1)]
|
||||
ADELICabinet, // Id Cabinet ADELI + N° employé
|
||||
#[deku(id = 2)]
|
||||
DRASS, // N° DRASS
|
||||
#[deku(id = 3)]
|
||||
FINESS, // N° FINESS + N° employé
|
||||
#[deku(id = 4)]
|
||||
SIREN, // N° SIREN + N° employé
|
||||
#[deku(id = 5)]
|
||||
SIRET, // N° SIRET + N° employé
|
||||
#[deku(id = 6)]
|
||||
RPPSCabinet, // Id Cabinet RPPS + N° employé
|
||||
#[deku(id = 8)]
|
||||
RPPS, // N° RPPS
|
||||
#[deku(id = 9)]
|
||||
ADELIEtudiantMedecin, // N° Etudiant Médecin type ADELI sur 9 caractères (information transmise par l’ANS)
|
||||
}
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct CivilityCode(pub NumericString);
|
||||
#[deku(ctx = "id: u8", id = "id")]
|
||||
pub enum CivilityCode {
|
||||
#[deku(id = 1)]
|
||||
Adjudant,
|
||||
#[deku(id = 2)]
|
||||
Amiral,
|
||||
#[deku(id = 3)]
|
||||
Aspirant,
|
||||
#[deku(id = 4)]
|
||||
Aumonier,
|
||||
#[deku(id = 5)]
|
||||
Capitaine,
|
||||
#[deku(id = 6)]
|
||||
Cardinal,
|
||||
#[deku(id = 7)]
|
||||
Chanoine,
|
||||
#[deku(id = 8)]
|
||||
Colonel,
|
||||
#[deku(id = 9)]
|
||||
Commandant,
|
||||
#[deku(id = 10)]
|
||||
Commissaire,
|
||||
#[deku(id = 11)]
|
||||
Conseiller,
|
||||
#[deku(id = 12)]
|
||||
Directeur,
|
||||
#[deku(id = 13)]
|
||||
Docteur,
|
||||
#[deku(id = 14)]
|
||||
Douanier,
|
||||
#[deku(id = 15)]
|
||||
Epouxse,
|
||||
#[deku(id = 16)]
|
||||
Eveque,
|
||||
#[deku(id = 17)]
|
||||
General,
|
||||
#[deku(id = 18)]
|
||||
Gouverneur,
|
||||
#[deku(id = 19)]
|
||||
Ingenieur,
|
||||
#[deku(id = 20)]
|
||||
Inspecteur,
|
||||
#[deku(id = 21)]
|
||||
Lieutenant,
|
||||
#[deku(id = 22)]
|
||||
Madame,
|
||||
#[deku(id = 23)]
|
||||
Mademoiselle,
|
||||
#[deku(id = 24)]
|
||||
Maitre,
|
||||
#[deku(id = 25)]
|
||||
Marechal,
|
||||
#[deku(id = 26)]
|
||||
Medecin,
|
||||
#[deku(id = 27)]
|
||||
Mesdames,
|
||||
#[deku(id = 28)]
|
||||
Mesdemoiselles,
|
||||
#[deku(id = 29)]
|
||||
Messieurs,
|
||||
#[deku(id = 30)]
|
||||
Monseigneur,
|
||||
#[deku(id = 31)]
|
||||
Monsieur,
|
||||
#[deku(id = 32)]
|
||||
NotreDame,
|
||||
#[deku(id = 33)]
|
||||
Pasteur,
|
||||
#[deku(id = 34)]
|
||||
Prefet,
|
||||
#[deku(id = 35)]
|
||||
President,
|
||||
#[deku(id = 36)]
|
||||
Professeur,
|
||||
#[deku(id = 37)]
|
||||
Recteur,
|
||||
#[deku(id = 38)]
|
||||
Sergent,
|
||||
#[deku(id = 39)]
|
||||
SousPrefet,
|
||||
#[deku(id = 40)]
|
||||
Technicien,
|
||||
#[deku(id = 41)]
|
||||
Veuve,
|
||||
}
|
||||
|
||||
|
||||
#[deku_derive(DekuRead)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[deku(id_type="u8")]
|
||||
pub enum CategoryCard {
|
||||
#[deku(id = 74)] // T
|
||||
Test,
|
||||
#[deku(id = 72)] // R
|
||||
Reelle,
|
||||
#[deku(id_pat = "_")]
|
||||
Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use deku::DekuContainerRead as _;
|
||||
use group_1_holder::CardPSType;
|
||||
use group_1_holder::{CardPSType, CategoryCard, CivilityCode, NationalIDType};
|
||||
|
||||
use crate::fsv_parsing::blocks::BlockHeader;
|
||||
|
||||
@ -150,12 +273,12 @@ mod tests {
|
||||
let offset = 3*8;
|
||||
let (_rest, holder) = group_1_holder::Holder::from_bytes((data::BUFFER, offset)).unwrap();
|
||||
assert_eq!(holder.card_type, CardPSType::CPS, "Card type");
|
||||
assert_eq!(holder.national_id_type.0.0, "8", "National ID type");
|
||||
assert_eq!(holder.national_id_type, NationalIDType::RPPS, "National ID type");
|
||||
assert_eq!(holder.national_id.0, "99700593686", "National Id");
|
||||
assert_eq!(holder.national_id_key.0, "6", "National ID Key");
|
||||
assert_eq!(holder.civility_code.0.0, "31", "Civility Code");
|
||||
assert_eq!(holder.civility_code, CivilityCode::Monsieur, "Civility Code");
|
||||
assert_eq!(holder.holder_lastname.0, "PHARMOFFICE RPPS0059368", "Holder Lastname");
|
||||
assert_eq!(holder.holder_firstname.0, "GILBERT", "Holder Firstname");
|
||||
assert!(holder.category_card.0.is_empty(), "Category card");
|
||||
assert_eq!(holder.category_card, CategoryCard::Unknown, "Category card");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user