}
}
+pub trait ToBytes<T, const N: usize> {
+ fn to_bytes(self, value: T) -> [u8; N];
+}
+impl ToBytes<f64, 8> for Endian {
+ fn to_bytes(self, value: f64) -> [u8; 8] {
+ match self {
+ Endian::Big => f64::to_be_bytes(value),
+ Endian::Little => f64::to_le_bytes(value),
+ }
+ }
+}
+
/// Parses an `N`-byte slice in one of the supported formats into native format
/// as type `T`.
pub trait Parse<T, const N: usize> {