1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
use std::convert::Infallible;
use std::fmt::{self, Display};
use std::str::FromStr;
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, Hash, Debug)]
#[serde(transparent)]
pub struct SubNoteId(pub String);
impl FromStr for SubNoteId {
type Err = Infallible;
fn from_str(s: &str) -> Result<SubNoteId, Infallible> {
Ok(SubNoteId(s.to_string()))
}
}
impl Display for SubNoteId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(f)
}
}
pub trait ConnectChannelRequest: Serialize {
type Incoming: DeserializeOwned + 'static;
type Outgoing: Serialize;
const NAME: &'static str;
}
impl<R: ?Sized> ConnectChannelRequest for &'_ R
where
R: ConnectChannelRequest,
{
type Incoming = R::Incoming;
type Outgoing = R::Outgoing;
const NAME: &'static str = R::NAME;
}
impl<R: ?Sized> ConnectChannelRequest for &'_ mut R
where
R: ConnectChannelRequest,
{
type Incoming = R::Incoming;
type Outgoing = R::Outgoing;
const NAME: &'static str = R::NAME;
}
impl<R: ?Sized> ConnectChannelRequest for Box<R>
where
R: ConnectChannelRequest,
{
type Incoming = R::Incoming;
type Outgoing = R::Outgoing;
const NAME: &'static str = R::NAME;
}
pub trait SubNoteEvent: DeserializeOwned + 'static {}
pub trait BroadcastEvent: DeserializeOwned + 'static {
const TYPE: &'static str;
}