Skip to content

Commit 80f6383

Browse files
committed
docs: improve JSON-RPC event docs
Replicate the docstrings from `src/events/payload.rs`.
1 parent fcd7026 commit 80f6383

File tree

1 file changed

+146
-40
lines changed

1 file changed

+146
-40
lines changed

deltachat-jsonrpc/src/api/types/events.rs

+146-40
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,25 @@ pub enum EventType {
8484
/// - Messages sent, received or removed
8585
/// - Chats created, deleted or archived
8686
/// - A draft has been set
87-
///
88-
/// `chatId` is set if only a single chat is affected by the changes, otherwise 0.
89-
/// `msgId` is set if only a single message is affected by the changes, otherwise 0.
9087
#[serde(rename_all = "camelCase")]
91-
MsgsChanged { chat_id: u32, msg_id: u32 },
88+
MsgsChanged {
89+
/// Set if only a single chat is affected by the changes, otherwise 0.
90+
chat_id: u32,
91+
92+
/// Set if only a single message is affected by the changes, otherwise 0.
93+
msg_id: u32
94+
},
9295

9396
/// Reactions for the message changed.
9497
#[serde(rename_all = "camelCase")]
9598
ReactionsChanged {
99+
/// ID of the chat which the message belongs to.
96100
chat_id: u32,
101+
102+
/// ID of the message for which reactions were changed.
97103
msg_id: u32,
104+
105+
/// ID of the contact whose reaction set is changed.
98106
contact_id: u32,
99107
},
100108

@@ -104,28 +112,50 @@ pub enum EventType {
104112
/// In addition to this event, ReactionsChanged is emitted.
105113
#[serde(rename_all = "camelCase")]
106114
IncomingReaction {
115+
/// ID of the chat which the message belongs to.
107116
chat_id: u32,
117+
118+
/// ID of the contact whose reaction set is changed.
108119
contact_id: u32,
120+
121+
/// ID of the message for which reactions were changed.
109122
msg_id: u32,
123+
124+
/// The reaction.
110125
reaction: String,
111126
},
112127

113128
/// Incoming webxdc info or summary update, should be notified.
114129
#[serde(rename_all = "camelCase")]
115130
IncomingWebxdcNotify {
131+
/// ID of the chat.
116132
chat_id: u32,
133+
134+
/// ID of the contact sending.
117135
contact_id: u32,
136+
137+
/// ID of the added info message or webxdc instance in case of summary change.
118138
msg_id: u32,
139+
140+
/// Text to notify.
119141
text: String,
142+
143+
/// Link assigned to this notification, if any.
120144
href: Option<String>,
121145
},
122146

123-
/// There is a fresh message. Typically, the user will show an notification
147+
/// There is a fresh message. Typically, the user will show a notification
124148
/// when receiving this message.
125149
///
126150
/// There is no extra #DC_EVENT_MSGS_CHANGED event sent together with this event.
127151
#[serde(rename_all = "camelCase")]
128-
IncomingMsg { chat_id: u32, msg_id: u32 },
152+
IncomingMsg {
153+
/// ID of the chat where the message is assigned.
154+
chat_id: u32,
155+
156+
/// ID of the message.
157+
msg_id: u32,
158+
},
129159

130160
/// Downloading a bunch of messages just finished. This is an
131161
/// event to allow the UI to only show one notification per message bunch,
@@ -141,21 +171,57 @@ pub enum EventType {
141171
/// A single message is sent successfully. State changed from DC_STATE_OUT_PENDING to
142172
/// DC_STATE_OUT_DELIVERED, see `Message.state`.
143173
#[serde(rename_all = "camelCase")]
144-
MsgDelivered { chat_id: u32, msg_id: u32 },
174+
MsgDelivered {
175+
/// ID of the chat which the message belongs to.
176+
chat_id: u32,
177+
178+
/// ID of the message that was successfully sent.
179+
msg_id: u32
180+
},
145181

146182
/// A single message could not be sent. State changed from DC_STATE_OUT_PENDING or DC_STATE_OUT_DELIVERED to
147183
/// DC_STATE_OUT_FAILED, see `Message.state`.
148184
#[serde(rename_all = "camelCase")]
149-
MsgFailed { chat_id: u32, msg_id: u32 },
185+
MsgFailed {
186+
/// ID of the chat which the message belongs to.
187+
chat_id: u32,
188+
189+
/// ID of the message that could not be sent.
190+
msg_id: u32
191+
},
150192

151193
/// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to
152194
/// DC_STATE_OUT_MDN_RCVD, see `Message.state`.
153195
#[serde(rename_all = "camelCase")]
154-
MsgRead { chat_id: u32, msg_id: u32 },
196+
MsgRead {
197+
/// ID of the chat which the message belongs to.
198+
chat_id: u32,
155199

156-
/// A single message is deleted.
200+
/// ID of the message that was read.
201+
msg_id: u32
202+
},
203+
204+
/// A single message was deleted.
205+
///
206+
/// This event means that the message will no longer appear in the messagelist.
207+
/// UI should remove the message from the messagelist
208+
/// in response to this event if the message is currently displayed.
209+
///
210+
/// The message may have been explicitly deleted by the user or expired.
211+
/// Internally the message may have been removed from the database,
212+
/// moved to the trash chat or hidden.
213+
///
214+
/// This event does not indicate the message
215+
/// deletion from the server.
157216
#[serde(rename_all = "camelCase")]
158-
MsgDeleted { chat_id: u32, msg_id: u32 },
217+
MsgDeleted {
218+
/// ID of the chat where the message was prior to deletion.
219+
/// Never 0 or trash chat.
220+
chat_id: u32,
221+
222+
/// ID of the deleted message. Never 0.
223+
msg_id: u32
224+
},
159225

160226
/// Chat changed. The name or the image of a chat group was changed or members were added or removed.
161227
/// Or the verify state of a chat has changed.
@@ -169,21 +235,29 @@ pub enum EventType {
169235

170236
/// Chat ephemeral timer changed.
171237
#[serde(rename_all = "camelCase")]
172-
ChatEphemeralTimerModified { chat_id: u32, timer: u32 },
238+
ChatEphemeralTimerModified {
239+
/// Chat ID.
240+
chat_id: u32,
241+
242+
/// New ephemeral timer value.
243+
timer: u32
244+
},
173245

174246
/// Contact(s) created, renamed, blocked or deleted.
175-
///
176-
/// @param data1 (int) If set, this is the contact_id of an added contact that should be selected.
177247
#[serde(rename_all = "camelCase")]
178-
ContactsChanged { contact_id: Option<u32> },
248+
ContactsChanged {
249+
/// If set, this is the contact_id of an added contact that should be selected.
250+
contact_id: Option<u32>
251+
},
179252

180253
/// Location of one or more contact has changed.
181-
///
182-
/// @param data1 (u32) contact_id of the contact for which the location has changed.
183-
/// If the locations of several contacts have been changed,
184-
/// this parameter is set to `None`.
185254
#[serde(rename_all = "camelCase")]
186-
LocationChanged { contact_id: Option<u32> },
255+
LocationChanged {
256+
/// contact_id of the contact for which the location has changed.
257+
/// If the locations of several contacts have been changed,
258+
/// this parameter is set to `None`.
259+
contact_id: Option<u32>
260+
},
187261

188262
/// Inform about the configuration progress started by configure().
189263
ConfigureProgress {
@@ -198,10 +272,13 @@ pub enum EventType {
198272

199273
/// Inform about the import/export progress started by imex().
200274
///
201-
/// @param data1 (usize) 0=error, 1-999=progress in permille, 1000=success and done
275+
/// @param data1 (usize)
202276
/// @param data2 0
203277
#[serde(rename_all = "camelCase")]
204-
ImexProgress { progress: usize },
278+
ImexProgress {
279+
/// 0=error, 1-999=progress in permille, 1000=success and done
280+
progress: usize
281+
},
205282

206283
/// A file has been exported. A file has been written by imex().
207284
/// This event may be sent multiple times by a single call to imex().
@@ -218,26 +295,34 @@ pub enum EventType {
218295
///
219296
/// These events are typically sent after a joiner has scanned the QR code
220297
/// generated by getChatSecurejoinQrCodeSvg().
221-
///
222-
/// @param data1 (int) ID of the contact that wants to join.
223-
/// @param data2 (int) Progress as:
224-
/// 300=vg-/vc-request received, typically shown as "bob@addr joins".
225-
/// 600=vg-/vc-request-with-auth received, vg-member-added/vc-contact-confirm sent, typically shown as "bob@addr verified".
226-
/// 800=vg-member-added-received received, shown as "bob@addr securely joined GROUP", only sent for the verified-group-protocol.
227-
/// 1000=Protocol finished for this contact.
228298
#[serde(rename_all = "camelCase")]
229-
SecurejoinInviterProgress { contact_id: u32, progress: usize },
299+
SecurejoinInviterProgress {
300+
/// ID of the contact that wants to join.
301+
contact_id: u32,
302+
303+
/// Progress as:
304+
/// 300=vg-/vc-request received, typically shown as "bob@addr joins".
305+
/// 600=vg-/vc-request-with-auth received, vg-member-added/vc-contact-confirm sent, typically shown as "bob@addr verified".
306+
/// 800=contact added to chat, shown as "bob@addr securely joined GROUP". Only for the verified-group-protocol.
307+
/// 1000=Protocol finished for this contact.
308+
progress: usize
309+
},
230310

231311
/// Progress information of a secure-join handshake from the view of the joiner
232312
/// (Bob, the person who scans the QR code).
233313
/// The events are typically sent while secureJoin(), which
234314
/// may take some time, is executed.
235-
/// @param data1 (int) ID of the inviting contact.
236-
/// @param data2 (int) Progress as:
237-
/// 400=vg-/vc-request-with-auth sent, typically shown as "alice@addr verified, introducing myself."
238-
/// (Bob has verified alice and waits until Alice does the same for him)
239315
#[serde(rename_all = "camelCase")]
240-
SecurejoinJoinerProgress { contact_id: u32, progress: usize },
316+
SecurejoinJoinerProgress {
317+
/// ID of the inviting contact.
318+
contact_id: u32,
319+
320+
/// Progress as:
321+
/// 400=vg-/vc-request-with-auth sent, typically shown as "alice@addr verified, introducing myself."
322+
/// (Bob has verified alice and waits until Alice does the same for him)
323+
/// 1000=vg-member-added/vc-contact-confirm received
324+
progress: usize
325+
},
241326

242327
/// The connectivity to the server changed.
243328
/// This means that you should refresh the connectivity view
@@ -258,22 +343,37 @@ pub enum EventType {
258343

259344
#[serde(rename_all = "camelCase")]
260345
WebxdcStatusUpdate {
346+
/// Message ID.
261347
msg_id: u32,
348+
349+
/// Status update ID.
262350
status_update_serial: u32,
263351
},
264352

265353
/// Data received over an ephemeral peer channel.
266354
#[serde(rename_all = "camelCase")]
267-
WebxdcRealtimeData { msg_id: u32, data: Vec<u8> },
355+
WebxdcRealtimeData {
356+
/// Message ID.
357+
msg_id: u32,
358+
359+
/// Realtime data.
360+
data: Vec<u8>
361+
},
268362

269363
/// Advertisement received over an ephemeral peer channel.
270364
/// This can be used by bots to initiate peer-to-peer communication from their side.
271365
#[serde(rename_all = "camelCase")]
272-
WebxdcRealtimeAdvertisementReceived { msg_id: u32 },
366+
WebxdcRealtimeAdvertisementReceived {
367+
/// Message ID of the webxdc instance.
368+
msg_id: u32
369+
},
273370

274371
/// Inform that a message containing a webxdc instance has been deleted
275372
#[serde(rename_all = "camelCase")]
276-
WebxdcInstanceDeleted { msg_id: u32 },
373+
WebxdcInstanceDeleted {
374+
/// ID of the deleted message.
375+
msg_id: u32
376+
},
277377

278378
/// Tells that the Background fetch was completed (or timed out).
279379
/// This event acts as a marker, when you reach this event you can be sure
@@ -289,7 +389,10 @@ pub enum EventType {
289389
/// Inform that a single chat list item changed and needs to be rerendered.
290390
/// If `chat_id` is set to None, then all currently visible chats need to be rerendered, and all not-visible items need to be cleared from cache if the UI has a cache.
291391
#[serde(rename_all = "camelCase")]
292-
ChatlistItemChanged { chat_id: Option<u32> },
392+
ChatlistItemChanged {
393+
/// ID of the changed chat
394+
chat_id: Option<u32>
395+
},
293396

294397
/// Inform that the list of accounts has changed (an account removed or added or (not yet implemented) the account order changes)
295398
///
@@ -306,7 +409,10 @@ pub enum EventType {
306409
AccountsItemChanged,
307410

308411
/// Inform than some events have been skipped due to event channel overflow.
309-
EventChannelOverflow { n: u64 },
412+
EventChannelOverflow {
413+
/// Number of events skipped.
414+
n: u64
415+
},
310416
}
311417

312418
impl From<CoreEventType> for EventType {

0 commit comments

Comments
 (0)