stablesats_shared/
macros.rs1#[macro_export]
2macro_rules! payload {
3 ($message_name:ident, $channel:literal) => {
4 impl MessagePayload for $message_name {
5 fn message_type() -> &'static str {
6 stringify!($message_name)
7 }
8
9 fn channel() -> &'static str {
10 concat!("galoy.stablesats.", $channel)
11 }
12 }
13 };
14}
15
16#[macro_export]
17macro_rules! string_wrapper {
18 ($name:ident) => {
19 #[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
20 #[serde(transparent)]
21 pub struct $name(pub(super) String);
22 impl std::fmt::Display for $name {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24 write!(f, "{}", self.0)
25 }
26 }
27 impl<S: Into<String>> From<S> for $name {
28 fn from(s: S) -> Self {
29 Self(s.into())
30 }
31 }
32 };
33}