pub(crate) mod detect;
pub(crate) mod legacy;
pub(crate) mod modern;
mod read;
pub use read::BdatFile;
const BDAT_MAGIC: [u8; 4] = [b'B', b'D', b'A', b'T'];
pub type SwitchEndian = byteorder::LittleEndian;
pub type WiiEndian = byteorder::BigEndian;
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum BdatVersion {
Legacy(LegacyVersion),
Modern,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum LegacyVersion {
Wii,
New3ds,
Switch,
X,
}
impl BdatVersion {
pub fn is_legacy(&self) -> bool {
*self != BdatVersion::Modern
}
pub fn is_modern(&self) -> bool {
!self.is_legacy()
}
pub fn are_labels_hashed(&self) -> bool {
self.is_modern()
}
}
impl LegacyVersion {
pub(crate) const fn table_header_size(&self) -> usize {
if self.is_wii_table_format() {
legacy::HEADER_SIZE_WII
} else {
legacy::HEADER_SIZE
}
}
pub(crate) const fn is_wii_table_format(&self) -> bool {
matches!(self, Self::Wii | Self::New3ds)
}
}
impl From<LegacyVersion> for BdatVersion {
fn from(value: LegacyVersion) -> Self {
Self::Legacy(value)
}
}