1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! `Serialize` and `Deserialize` implementations for extensible events (MSC1767).

use js_int::UInt;
use serde::Deserialize;

use super::Amplitude;

impl<'de> Deserialize<'de> for Amplitude {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let uint = UInt::deserialize(deserializer)?;
        Ok(Self(uint.min(Self::MAX.into())))
    }
}