medea_jason/platform/rtc_stats.rs
1//! Platform-agnostic functionality of [`platform::RtcStats`].
2
3use std::rc::Rc;
4
5use derive_more::with_trait::{Display, From};
6
7use crate::{platform, utils::Caused};
8
9/// Errors which can occur during deserialization of a [`RtcStatsType`].
10///
11/// [`RtcStatsType`]: medea_client_api_proto::stats::RtcStatsType
12#[derive(Caused, Clone, Debug, Display, From)]
13#[cause(error = platform::Error)]
14pub enum RtcStatsError {
15 /// [RTCStats.id][1] is undefined.
16 ///
17 /// [1]: https://w3.org/TR/webrtc#dom-rtcstats-id
18 #[display("RTCStats.id is undefined")]
19 UndefinedId,
20
21 /// [RTCStats.stats] are undefined.
22 ///
23 /// [1]: https://w3.org/TR/webrtc-stats/#dfn-stats-object
24 #[display("RTCStats.stats are undefined")]
25 UndefinedStats,
26
27 /// Some platform error occurred.
28 #[display("Unexpected platform error: {_0}")]
29 Platform(platform::Error),
30
31 /// [`platform::RtcStats`] deserialization error.
32 #[display("Failed to deserialize into RtcStats: {_0}")]
33 ParseError(Rc<serde_json::Error>),
34}