123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #![allow(dead_code)]
- use binrw::{BinRead, BinWrite};
- use crate::{array_of::ArrayOf, field_of::FieldOf};
- /// Generic field with structure of length + data
- pub type Field = ArrayOf<u8>;
- pub type U32 = FieldOf<u32>;
- pub type U16 = FieldOf<u16>;
- pub type Double = FieldOf<f64>;
- pub type Color = FieldOf<Rgba>;
- pub type WString = ArrayOf<u16>;
- impl From<&WString> for String {
- fn from(value: &WString) -> Self {
- String::from_utf16_lossy(value)
- }
- }
- impl From<String> for WString {
- fn from(value: String) -> Self {
- let value: Vec<u16> = value.encode_utf16().collect();
- Self { value }
- }
- }
- #[derive(BinRead, BinWrite, PartialEq, Debug)]
- pub struct Rgba {
- red: u8,
- green: u8,
- blue: u8,
- alpha: u8,
- }
- #[derive(BinRead, BinWrite, PartialEq, Debug)]
- pub struct Point {
- x: f64,
- y: f64,
- }
|