bfbb/
endian.rs

1use crate::game_state::{GameMode, GameOstrich, GameState};
2
3pub trait EndianAware {
4    const NEEDS_SWAP: bool;
5}
6
7macro_rules! impl_aware {
8    ( false: $( $f:ty ),*; true: $( $t:ty ),* )=> {
9        $( impl_aware!(false, $f); )*
10        $( impl_aware!(true,  $t); )*
11    };
12    ( $needs_swap:expr, $typ:ty) => {
13        impl EndianAware for $typ {
14            const NEEDS_SWAP: bool = $needs_swap;
15        }
16    };
17}
18
19impl_aware!(false: bool, u8, GameMode, GameState, GameOstrich; true: i16, u32);
20impl<const N: usize> EndianAware for [u8; N] {
21    const NEEDS_SWAP: bool = false;
22}