graphql_ws_client/client/
conection_id.rs1use std::num::NonZero;
2
3#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
4pub struct SubscriptionId(NonZero<usize>);
9
10impl SubscriptionId {
11 pub(super) fn new(id: usize) -> Option<Self> {
12 Some(SubscriptionId(NonZero::new(id)?))
13 }
14
15 #[expect(clippy::inherent_to_string)] pub(super) fn to_string(self) -> String {
17 self.0.to_string()
18 }
19
20 pub(super) fn from_str(s: &str) -> Option<Self> {
21 SubscriptionId::new(s.parse::<usize>().ok()?)
22 }
23}