use std::collections::BTreeMap;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ContainerKind {
Mdx,
Mdd,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KeyOrdinal(u64);
impl KeyOrdinal {
pub const fn new(value: u64) -> Self {
Self(value)
}
pub const fn get(self) -> u64 {
self.0
}
}
impl From<u64> for KeyOrdinal {
fn from(value: u64) -> Self {
Self::new(value)
}
}
impl From<KeyOrdinal> for u64 {
fn from(value: KeyOrdinal) -> Self {
value.get()
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct EncryptionMode(pub u8);
impl EncryptionMode {
pub fn has_keyword_header(self) -> bool {
self.0 & 0b01 != 0
}
pub fn has_keyword_index(self) -> bool {
self.0 & 0b10 != 0
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Header {
pub raw_xml: String,
pub tag_name: String,
pub attributes: BTreeMap<String, String>,
pub generated_by_engine_version: String,
pub required_engine_version: String,
pub encoding_label: Option<String>,
pub format: Option<String>,
pub key_case_sensitive: bool,
pub strip_key: bool,
pub encrypted: u8,
pub register_by: Option<String>,
pub reg_code: Option<String>,
pub description: Option<String>,
pub title: Option<String>,
pub creation_date: Option<String>,
}
impl Header {
pub fn encryption_mode(&self) -> EncryptionMode {
EncryptionMode(self.encrypted)
}
pub fn is_v2(&self) -> bool {
self.generated_by_engine_version
.split('.')
.next()
.and_then(|v| v.parse::<u32>().ok())
.unwrap_or(0)
>= 2
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Passcode {
pub reg_code_hex: String,
pub user_id: String,
}
#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct OpenOptions {
pub passcode: Option<Passcode>,
}