relay_event_schema/protocol/contexts/
monitor.rs1use relay_protocol::{Annotated, Empty, FromValue, IntoValue, Object, Value};
2
3use crate::processor::ProcessValue;
4
5#[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)]
7pub struct MonitorContext(#[metastructure(pii = "maybe")] pub Object<Value>);
8
9impl From<Object<Value>> for MonitorContext {
10 fn from(object: Object<Value>) -> Self {
11 Self(object)
12 }
13}
14
15impl std::ops::Deref for MonitorContext {
16 type Target = Object<Value>;
17
18 fn deref(&self) -> &Self::Target {
19 &self.0
20 }
21}
22
23impl std::ops::DerefMut for MonitorContext {
24 fn deref_mut(&mut self) -> &mut Self::Target {
25 &mut self.0
26 }
27}
28
29impl super::DefaultContext for MonitorContext {
30 fn default_key() -> &'static str {
31 "monitor"
32 }
33
34 fn from_context(context: super::Context) -> Option<Self> {
35 match context {
36 super::Context::Monitor(c) => Some(*c),
37 _ => None,
38 }
39 }
40
41 fn cast(context: &super::Context) -> Option<&Self> {
42 match context {
43 super::Context::Monitor(c) => Some(c),
44 _ => None,
45 }
46 }
47
48 fn cast_mut(context: &mut super::Context) -> Option<&mut Self> {
49 match context {
50 super::Context::Monitor(c) => Some(c),
51 _ => None,
52 }
53 }
54
55 fn into_context(self) -> super::Context {
56 super::Context::Monitor(Box::new(self))
57 }
58}