added DST, EXP, JEF, VP3
Some checks failed
CI / Lint and Test (pull_request) Successful in 36s
CI / Version Check (pull_request) Failing after 3s

This commit is contained in:
2026-03-31 08:08:36 +02:00
parent 512f49ab38
commit 40ccf9ded4
16 changed files with 1215 additions and 262 deletions

34
rustitch/src/format.rs Normal file
View File

@@ -0,0 +1,34 @@
use std::path::Path;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Format {
Pes,
Dst,
Exp,
Jef,
Vp3,
}
/// Detect format from file content (magic bytes).
pub fn detect_from_bytes(data: &[u8]) -> Option<Format> {
if data.len() >= 4 && &data[0..4] == b"#PES" {
return Some(Format::Pes);
}
if data.len() >= 5 && &data[0..5] == b"%vsm%" {
return Some(Format::Vp3);
}
None
}
/// Detect format from file extension.
pub fn detect_from_extension(path: &Path) -> Option<Format> {
let ext = path.extension()?.to_str()?;
match ext.to_ascii_lowercase().as_str() {
"pes" => Some(Format::Pes),
"dst" => Some(Format::Dst),
"exp" => Some(Format::Exp),
"jef" => Some(Format::Jef),
"vp3" => Some(Format::Vp3),
_ => None,
}
}