Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit 8473b12

Browse files
committed
doc
1 parent 66e8ee0 commit 8473b12

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

src/types/gateway/payload.rs

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,99 @@
11
use serde::{Deserialize, Serialize};
22
use serde_with::{serde_as, DisplayFromStr};
33

4+
use crate::types::FederationId;
5+
46
use super::Payload;
57

68
#[serde_as]
79
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
810
#[serde(rename_all = "camelCase")]
11+
/// Sent by clients to the server to keep the WebSocket connection alive.
12+
///
13+
/// ## Reference
14+
///
15+
/// See sections [3.2.3.8](https://docs.polyphony.chat/Protocol%20Specifications/core/#3238-heartbeat-and-heartbeat-ack-events)
16+
/// or [3.2.2](https://docs.polyphony.chat/Protocol%20Specifications/core/#322-heartbeats) of the
17+
/// polyproto specification.
918
pub struct Heartbeat {
1019
#[serde_as(as = "DisplayFromStr")]
20+
/// The lowest received sequence number.
1121
pub from: u64,
1222
#[serde_as(as = "DisplayFromStr")]
23+
/// The highest received sequence number.
1324
pub to: u64,
1425
#[serde_as(as = "Vec<DisplayFromStr>")]
1526
#[serde(skip_serializing_if = "Vec::is_empty")]
1627
#[serde(default)]
28+
/// Sequence numbers in range `> from` and `< to`, which were not received by the client.
1729
pub except: Vec<u64>,
1830
}
1931

2032
#[serde_as]
2133
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
2234
#[serde(rename_all = "camelCase")]
35+
/// Sent by the server upon establishing a WebSocket connection.
36+
///
37+
/// ## Reference
38+
///
39+
/// See section [3.2.3.1](https://docs.polyphony.chat/Protocol%20Specifications/core/#3231-hello-event)
40+
/// of the polyproto specification.
2341
pub struct Hello {
42+
/// Heartbeat interval, in milliseconds
2443
#[serde_as(as = "DisplayFromStr")]
2544
pub heartbeat_interval: u32,
45+
#[serde(default)]
2646
#[serde(skip_serializing_if = "Option::is_none")]
47+
/// Whether there is an unfinished migration which can be resumed.
48+
///
49+
/// ## Warning
50+
///
51+
/// Read [security information regarding this object](https://docs.polyphony.chat/Protocol%20Specifications/core/#:~:text=of%20the%20migration.-,danger,-User-operated%20clients)
52+
/// before working with it.
2753
pub active_migration: Option<ActiveMigration>,
2854
}
2955

3056
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3157
#[serde(rename_all = "camelCase")]
58+
/// Supplementary information about an unfinished, resumeable migration process.
3259
pub struct ActiveMigration {
33-
pub from: String,
34-
pub to: String,
60+
/// Migration source; Federation ID
61+
pub from: FederationId,
62+
/// Migration target; Federation ID
63+
pub to: FederationId,
3564
}
3665

3766
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3867
#[serde(rename_all = "camelCase")]
68+
/// Identifying information about the client, namely a session token.
3969
pub struct Identify {
70+
/// Session token.
4071
pub token: String,
4172
}
4273

4374
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
4475
#[serde(rename_all = "camelCase")]
76+
/// Information about a new session that has logged in on the server.
77+
///
78+
/// ## Reference
79+
///
80+
/// See chapters [3.2.3.4](https://docs.polyphony.chat/Protocol%20Specifications/core/#3234-new-session-event)
81+
/// and [4.3](https://docs.polyphony.chat/Protocol%20Specifications/core/#43-protection-against-misuse-by-malicious-home-servers)
82+
/// of the polyproto specification.
4583
pub struct NewSession {
84+
/// PEM encoded certificate of the new session
4685
pub cert: String,
4786
}
4887

4988
#[serde_as]
5089
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
5190
#[serde(rename_all = "camelCase")]
91+
/// Information from a server informing clients about the fact that an actor certificate has been
92+
/// prematurely revoked.
93+
// TODO this seems useless. should likely be an updated certificate instead.
5294
pub struct ActorCertificateInvalidation {
53-
#[serde_as(as = "DisplayFromStr")]
54-
pub serial: u64,
55-
#[serde_as(as = "DisplayFromStr")]
56-
pub invalid_since: u64,
57-
pub signature: String,
95+
#[serde(flatten)]
96+
pub certificate: CachedIdCert,
5897
}
5998

6099
#[serde_as]

0 commit comments

Comments
 (0)