nostr_types/types/
subscription_id.rs

1use derive_more::{AsMut, AsRef, Deref, From, FromStr, Into};
2use serde::{Deserialize, Serialize};
3#[cfg(feature = "speedy")]
4use speedy::{Readable, Writable};
5
6/// A random client-chosen string used to refer to a subscription
7#[derive(
8    AsMut, AsRef, Clone, Debug, Deref, Deserialize, Eq, From, FromStr, Into, PartialEq, Serialize,
9)]
10#[cfg_attr(feature = "speedy", derive(Readable, Writable))]
11pub struct SubscriptionId(pub String);
12
13impl SubscriptionId {
14    // Mock data for testing
15    #[allow(dead_code)]
16    pub(crate) fn mock() -> SubscriptionId {
17        SubscriptionId("lk234js09".to_owned())
18    }
19}
20
21#[cfg(test)]
22mod test {
23    use super::*;
24
25    test_serde! {SubscriptionId, test_subscription_id_serde}
26}