basic_field.rs 608 B

123456789101112131415161718192021222324252627282930
  1. #![allow(dead_code)]
  2. use binrw::{BinRead, BinWrite};
  3. use crate::{array_of::ArrayOf, field_of::FieldOf};
  4. /// Wrapper for basic types determined by initial u32 size
  5. #[derive(BinRead, BinWrite, PartialEq, Debug)]
  6. pub enum BasicField {
  7. U16(FieldOf<u16>),
  8. U32(FieldOf<u32>),
  9. Double(FieldOf<f64>),
  10. }
  11. /// Generic field with structure of length + data
  12. pub type Field = ArrayOf<u8>;
  13. #[derive(BinRead, BinWrite, PartialEq, Debug)]
  14. pub struct Rgba {
  15. red: u8,
  16. green: u8,
  17. blue: u8,
  18. alpha: u8,
  19. }
  20. #[derive(BinRead, BinWrite, PartialEq, Debug)]
  21. pub struct Point {
  22. x: f64,
  23. y: f64,
  24. }