relay_event_schema/protocol/contexts/
nel.rs1use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};
2
3use crate::processor::ProcessValue;
4use crate::protocol::{IpAddr, NetworkReportPhases};
5
6#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
14pub struct NelContext {
15 pub error_type: Annotated<String>,
17 #[metastructure(pii = "maybe")]
19 pub server_ip: Annotated<IpAddr>,
20 pub elapsed_time: Annotated<u64>,
22 pub phase: Annotated<NetworkReportPhases>,
24 pub sampling_fraction: Annotated<f64>,
26 #[metastructure(additional_properties, pii = "maybe")]
28 pub other: Object<Value>,
29}
30
31impl super::DefaultContext for NelContext {
32 fn default_key() -> &'static str {
33 "nel"
34 }
35
36 fn from_context(context: super::Context) -> Option<Self> {
37 match context {
38 super::Context::Nel(c) => Some(*c),
39 _ => None,
40 }
41 }
42
43 fn cast(context: &super::Context) -> Option<&Self> {
44 match context {
45 super::Context::Nel(c) => Some(c),
46 _ => None,
47 }
48 }
49
50 fn cast_mut(context: &mut super::Context) -> Option<&mut Self> {
51 match context {
52 super::Context::Nel(c) => Some(c),
53 _ => None,
54 }
55 }
56
57 fn into_context(self) -> super::Context {
58 super::Context::Nel(Box::new(self))
59 }
60}