Skip to main content

aleph_types/
channel.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
4pub struct Channel(String);
5
6impl From<String> for Channel {
7    fn from(value: String) -> Self {
8        Self(value)
9    }
10}
11
12/// Macro for creating Channel instances from string literals.
13///
14/// # Example
15///
16/// ```
17/// use aleph_types::channel;
18/// let channel = channel!("MY-CHANNEL");
19/// ```
20#[macro_export]
21macro_rules! channel {
22    ($channel:expr) => {{ $crate::channel::Channel::from($channel.to_string()) }};
23}