serde_content/ser/
number.rs

1use crate::Number;
2use serde::ser;
3
4impl ser::Serialize for Number {
5    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
6    where
7        S: ser::Serializer,
8    {
9        match *self {
10            Number::I8(v) => serializer.serialize_i8(v),
11            Number::U8(v) => serializer.serialize_u8(v),
12            Number::I16(v) => serializer.serialize_i16(v),
13            Number::U16(v) => serializer.serialize_u16(v),
14            Number::I32(v) => serializer.serialize_i32(v),
15            Number::U32(v) => serializer.serialize_u32(v),
16            Number::F32(v) => serializer.serialize_f32(v),
17            Number::I64(v) => serializer.serialize_i64(v),
18            Number::U64(v) => serializer.serialize_u64(v),
19            Number::F64(v) => serializer.serialize_f64(v),
20            Number::I128(v) => serializer.serialize_i128(v),
21            Number::U128(v) => serializer.serialize_u128(v),
22        }
23    }
24}