1use std::io::Cursor;
5
6use crate::ByteSpan;
7use binrw::BinRead;
8use binrw::binrw;
9
10#[binrw]
11#[derive(Debug)]
12#[brw(little)]
13struct ScdHeader {
14 #[br(count = 4)]
15 #[bw(pad_size_to = 4)]
16 #[bw(map = |x : &String | x.as_bytes())]
17 #[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
18 pub file_type: String,
19
20 #[br(count = 4)]
21 #[bw(pad_size_to = 4)]
22 #[bw(map = |x : &String | x.as_bytes())]
23 #[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
24 pub sub_type: String,
25
26 version: u32,
27 endian_type: u32,
28 alignment_bits: u8,
29 offset: u16,
30 datetime: u64,
31
32 #[br(pad_before = 4)]
33 sound_count: u16,
34 track_count: u16,
35 audio_count: u16,
36 number: u16,
37
38 track_offset: u32,
39 audio_offset: u32,
40 layout_offset: u32,
41 routing_offset: u32,
42 attribute_offset: u32,
43
44 #[br(pad_after = 2)]
45 end_of_file_padding_size: u16,
46}
47
48#[derive(Debug)]
49pub struct Scd {}
50
51impl Scd {
52 pub fn from_existing(buffer: ByteSpan) -> Option<Self> {
54 let mut cursor = Cursor::new(buffer);
55 ScdHeader::read(&mut cursor).ok()?;
56
57 Some(Scd {})
58 }
59}