diameter_interface/modeling/avp/
float64.rs

1use crate::errors::DiameterResult;
2use crate::impl_avp_data_encode_to_numbers;
3use crate::modeling::avp::avp::AvpValue;
4use crate::modeling::avp::AvpData;
5use std::io::Read;
6
7pub type Float64 = AvpData<f64>;
8
9impl Float64 {
10    impl_avp_data_encode_to_numbers!(Float64, f64);
11
12    pub(super) fn decode_from<R: Read>(reader: &mut R) -> DiameterResult<AvpData<f64>> {
13        let mut buffer = [0u8; 8];
14        reader.read_exact(&mut buffer)?;
15        let num = f64::from_be_bytes(buffer);
16        Ok(Float64::new(num))
17    }
18
19    pub(super) fn len(&self) -> u32 {
20        8
21    }
22}
23
24impl Into<AvpValue> for Float64 {
25    fn into(self) -> AvpValue {
26        AvpValue::Float64(self)
27    }
28}