Skip to content

Commit 5c3d1e7

Browse files
WofWcaHocuri
andauthored
docs: improve docstrings (#6496)
Co-authored-by: Hocuri <hocuri@gmx.de>
1 parent 4fb24d0 commit 5c3d1e7

File tree

2 files changed

+153
-43
lines changed

2 files changed

+153
-43
lines changed

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

Lines changed: 149 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,45 +84,78 @@ 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

101-
/// Incoming reaction, should be notified.
109+
/// A reaction to one's own sent message received.
110+
/// Typically, the UI will show a notification for that.
111+
///
112+
/// In addition to this event, ReactionsChanged is emitted.
102113
#[serde(rename_all = "camelCase")]
103114
IncomingReaction {
115+
/// ID of the chat which the message belongs to.
104116
chat_id: u32,
117+
118+
/// ID of the contact whose reaction set is changed.
105119
contact_id: u32,
120+
121+
/// ID of the message for which reactions were changed.
106122
msg_id: u32,
123+
124+
/// The reaction.
107125
reaction: String,
108126
},
109127

110128
/// Incoming webxdc info or summary update, should be notified.
111129
#[serde(rename_all = "camelCase")]
112130
IncomingWebxdcNotify {
131+
/// ID of the chat.
113132
chat_id: u32,
133+
134+
/// ID of the contact sending.
114135
contact_id: u32,
136+
137+
/// ID of the added info message or webxdc instance in case of summary change.
115138
msg_id: u32,
139+
140+
/// Text to notify.
116141
text: String,
142+
143+
/// Link assigned to this notification, if any.
117144
href: Option<String>,
118145
},
119146

120-
/// 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
121148
/// when receiving this message.
122149
///
123150
/// There is no extra #DC_EVENT_MSGS_CHANGED event sent together with this event.
124151
#[serde(rename_all = "camelCase")]
125-
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+
},
126159

127160
/// Downloading a bunch of messages just finished. This is an
128161
/// event to allow the UI to only show one notification per message bunch,
@@ -138,21 +171,57 @@ pub enum EventType {
138171
/// A single message is sent successfully. State changed from DC_STATE_OUT_PENDING to
139172
/// DC_STATE_OUT_DELIVERED, see `Message.state`.
140173
#[serde(rename_all = "camelCase")]
141-
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+
},
142181

143182
/// A single message could not be sent. State changed from DC_STATE_OUT_PENDING or DC_STATE_OUT_DELIVERED to
144183
/// DC_STATE_OUT_FAILED, see `Message.state`.
145184
#[serde(rename_all = "camelCase")]
146-
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+
},
147192

148193
/// A single message is read by the receiver. State changed from DC_STATE_OUT_DELIVERED to
149194
/// DC_STATE_OUT_MDN_RCVD, see `Message.state`.
150195
#[serde(rename_all = "camelCase")]
151-
MsgRead { chat_id: u32, msg_id: u32 },
196+
MsgRead {
197+
/// ID of the chat which the message belongs to.
198+
chat_id: u32,
199+
200+
/// ID of the message that was read.
201+
msg_id: u32,
202+
},
152203

153-
/// A single message is deleted.
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.
154216
#[serde(rename_all = "camelCase")]
155-
MsgDeleted { chat_id: u32, msg_id: u32 },
217+
MsgDeleted {
218+
/// ID of the chat where the message was prior to deletion.
219+
/// Never 0.
220+
chat_id: u32,
221+
222+
/// ID of the deleted message. Never 0.
223+
msg_id: u32,
224+
},
156225

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

167236
/// Chat ephemeral timer changed.
168237
#[serde(rename_all = "camelCase")]
169-
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+
},
170245

171246
/// Contact(s) created, renamed, blocked or deleted.
172-
///
173-
/// @param data1 (int) If set, this is the contact_id of an added contact that should be selected.
174247
#[serde(rename_all = "camelCase")]
175-
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+
},
176252

177253
/// Location of one or more contact has changed.
178-
///
179-
/// @param data1 (u32) contact_id of the contact for which the location has changed.
180-
/// If the locations of several contacts have been changed,
181-
/// this parameter is set to `None`.
182254
#[serde(rename_all = "camelCase")]
183-
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+
},
184261

185262
/// Inform about the configuration progress started by configure().
186263
ConfigureProgress {
@@ -195,10 +272,11 @@ pub enum EventType {
195272

196273
/// Inform about the import/export progress started by imex().
197274
///
198-
/// @param data1 (usize) 0=error, 1-999=progress in permille, 1000=success and done
199-
/// @param data2 0
200275
#[serde(rename_all = "camelCase")]
201-
ImexProgress { progress: usize },
276+
ImexProgress {
277+
/// 0=error, 1-999=progress in permille, 1000=success and done
278+
progress: usize,
279+
},
202280

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

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

239325
/// The connectivity to the server changed.
240326
/// This means that you should refresh the connectivity view
@@ -255,22 +341,37 @@ pub enum EventType {
255341

256342
#[serde(rename_all = "camelCase")]
257343
WebxdcStatusUpdate {
344+
/// Message ID.
258345
msg_id: u32,
346+
347+
/// Status update ID.
259348
status_update_serial: u32,
260349
},
261350

262351
/// Data received over an ephemeral peer channel.
263352
#[serde(rename_all = "camelCase")]
264-
WebxdcRealtimeData { msg_id: u32, data: Vec<u8> },
353+
WebxdcRealtimeData {
354+
/// Message ID.
355+
msg_id: u32,
356+
357+
/// Realtime data.
358+
data: Vec<u8>,
359+
},
265360

266361
/// Advertisement received over an ephemeral peer channel.
267362
/// This can be used by bots to initiate peer-to-peer communication from their side.
268363
#[serde(rename_all = "camelCase")]
269-
WebxdcRealtimeAdvertisementReceived { msg_id: u32 },
364+
WebxdcRealtimeAdvertisementReceived {
365+
/// Message ID of the webxdc instance.
366+
msg_id: u32,
367+
},
270368

271369
/// Inform that a message containing a webxdc instance has been deleted
272370
#[serde(rename_all = "camelCase")]
273-
WebxdcInstanceDeleted { msg_id: u32 },
371+
WebxdcInstanceDeleted {
372+
/// ID of the deleted message.
373+
msg_id: u32,
374+
},
274375

275376
/// Tells that the Background fetch was completed (or timed out).
276377
/// This event acts as a marker, when you reach this event you can be sure
@@ -286,7 +387,10 @@ pub enum EventType {
286387
/// Inform that a single chat list item changed and needs to be rerendered.
287388
/// 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.
288389
#[serde(rename_all = "camelCase")]
289-
ChatlistItemChanged { chat_id: Option<u32> },
390+
ChatlistItemChanged {
391+
/// ID of the changed chat
392+
chat_id: Option<u32>,
393+
},
290394

291395
/// Inform that the list of accounts has changed (an account removed or added or (not yet implemented) the account order changes)
292396
///
@@ -303,7 +407,10 @@ pub enum EventType {
303407
AccountsItemChanged,
304408

305409
/// Inform than some events have been skipped due to event channel overflow.
306-
EventChannelOverflow { n: u64 },
410+
EventChannelOverflow {
411+
/// Number of events skipped.
412+
n: u64,
413+
},
307414
}
308415

309416
impl From<CoreEventType> for EventType {

src/events/payload.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ pub enum EventType {
9595
contact_id: ContactId,
9696
},
9797

98-
/// Reactions for the message changed.
98+
/// A reaction to one's own sent message received.
99+
/// Typically, the UI will show a notification for that.
100+
///
101+
/// In addition to this event, ReactionsChanged is emitted.
99102
IncomingReaction {
100103
/// ID of the chat which the message belongs to.
101104
chat_id: ChatId,

0 commit comments

Comments
 (0)