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
//! Channels: ephemeral, typed traffic between the people watching the same
//! thing, with presence.
//!
//! A channel is a join argument struct and two types:
//!
//! ```ignore
//! #[rpc::channel(message = Typing, presence = Presence, authorize = may_join)]
//! pub struct Chat {
//! pub channel: Id<Channel>,
//! }
//!
//! async fn may_join(cx: &rpc::QueryCx, chat: &Chat) -> rpc::Result<()> {
//! let me = cx.require_user::<User>()?;
//! Member::query()
//! .filter(|member| member.channel.eq(chat.channel) & member.user.eq(me))
//! .one(cx.db())
//! .await?;
//! Ok(())
//! }
//! ```
//!
//! Joining is checked once, as the caller, and re-checked when the
//! connection's identity changes. Signals travel at most once and are never
//! stored: anything that must survive belongs in a live table and a live
//! query. Presence is who is in the channel now, with whatever state each
//! connection joined with.
use Serialize;
use DeserializeOwned;
/// One kind of channel: its join arguments, the messages it carries, and
/// the presence each member shows.
///
/// Declare one with `#[rpc::channel(...)]`, which implements this and
/// registers it with a server build.
/// Checks a channel's join arguments, where the macro names them.
pub const
/// Checks a channel's message type, where the macro names it.
pub const
/// Checks a channel's presence type, where the macro names it.
pub const