1use std::io::Cursor;
5
6use crate::ByteSpan;
7use binrw::BinRead;
8use binrw::binrw;
9
10#[binrw]
11#[derive(Debug)]
12#[brw(little)]
13struct SgbHeader {
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 identifier: String,
19
20 file_size: i32,
21 total_chunk_count: i32,
22}
23
24#[derive(Debug)]
25pub struct Sgb {}
26
27impl Sgb {
28 pub fn from_existing(buffer: ByteSpan) -> Option<Self> {
30 let mut cursor = Cursor::new(buffer);
31 SgbHeader::read(&mut cursor).ok()?;
32
33 Some(Sgb {})
34 }
35}