xxai_msgpacker/pack/
float.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::{Format, Packable};
use core::iter;

impl Packable for f32 {
    fn pack<T>(&self, buf: &mut T) -> usize
    where
        T: Extend<u8>,
    {
        buf.extend(iter::once(Format::FLOAT32).chain(self.to_be_bytes()));
        5
    }
}

impl Packable for f64 {
    fn pack<T>(&self, buf: &mut T) -> usize
    where
        T: Extend<u8>,
    {
        buf.extend(iter::once(Format::FLOAT64).chain(self.to_be_bytes()));
        9
    }
}