physis/
skp.rs

1// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4use std::io::Cursor;
5
6use crate::ByteSpan;
7use binrw::BinRead;
8use binrw::binrw;
9
10#[binrw]
11#[derive(Debug)]
12#[brw(little)]
13struct SkpHeader {
14    magic: i32, // TODO: what magic?
15
16    #[br(count = 4)]
17    #[bw(pad_size_to = 4)]
18    #[bw(map = |x : &String | x.as_bytes())]
19    #[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
20    pub version: String,
21}
22
23#[derive(Debug)]
24pub struct Skp {}
25
26impl Skp {
27    /// Reads an existing ULD file
28    pub fn from_existing(buffer: ByteSpan) -> Option<Self> {
29        let mut cursor = Cursor::new(buffer);
30        SkpHeader::read(&mut cursor).ok()?;
31
32        Some(Skp {})
33    }
34}