use bytes::BufMut;
use crate::{format::Format, Packable};
impl Packable for f32 {
fn pack<T>(&self, buf: &mut T) -> usize
where
T: BufMut,
{
let mut s = [0u8; 5];
s[0] = Format::FLOAT32;
s[1..].copy_from_slice(&self.to_be_bytes());
buf.put_slice(&s);
5
}
}
impl Packable for f64 {
fn pack<T>(&self, buf: &mut T) -> usize
where
T: BufMut,
{
let mut s = [0u8; 9];
s[0] = Format::FLOAT64;
s[1..].copy_from_slice(&self.to_be_bytes());
buf.put_slice(&s);
9
}
}