bifrostlink/
notification.rs1use serde::{de::DeserializeOwned, Serialize};
2
3pub trait Notification {
4 fn name() -> u16;
5}
6#[macro_export]
7macro_rules! notification {
8 (($id:literal )$name:ident $(<$($generic:ident $(: $bound:ident)?),+ $(,)?>)?) => {
9 impl $(<$($generic $(: $bound)?),+>)? $crate::Notification for $name $(<$($generic),+>)? {
10 fn name() -> u16 {
11 $id
12 }
13 }
14 };
15}
16
17pub trait OutgoingNotification: Notification + Serialize {}
18impl<N: Notification + Serialize> OutgoingNotification for N {}
19pub trait IncomingNotification: Notification + DeserializeOwned {}
20impl<N: Notification + DeserializeOwned> IncomingNotification for N {}
21
22impl<T> Notification for &T
23where
24 T: Notification,
25{
26 fn name() -> u16 {
27 T::name()
28 }
29}