Skip to main content

simploxide_api_types/
events.rs

1#[allow(unused_imports)]
2use crate::commands::*;
3use crate::*;
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6#[serde(tag = "type")]
7#[non_exhaustive]
8pub enum Event {
9    /// Contact connection events
10    #[serde(rename = "contactConnected")]
11    ContactConnected(Arc<ContactConnected>),
12    /// Contact connection events
13    #[serde(rename = "contactUpdated")]
14    ContactUpdated(Arc<ContactUpdated>),
15    /// Contact connection events
16    #[serde(rename = "contactDeletedByContact")]
17    ContactDeletedByContact(Arc<ContactDeletedByContact>),
18    /// Contact connection events
19    #[serde(rename = "receivedContactRequest")]
20    ReceivedContactRequest(Arc<ReceivedContactRequest>),
21    /// Contact connection events
22    #[serde(rename = "newMemberContactReceivedInv")]
23    NewMemberContactReceivedInv(Arc<NewMemberContactReceivedInv>),
24    /// Contact connection events
25    #[serde(rename = "contactSndReady")]
26    ContactSndReady(Arc<ContactSndReady>),
27    /// Message events
28    #[serde(rename = "newChatItems")]
29    NewChatItems(Arc<NewChatItems>),
30    /// Message events
31    #[serde(rename = "chatItemReaction")]
32    ChatItemReaction(Arc<ChatItemReaction>),
33    /// Message events
34    #[serde(rename = "chatItemsDeleted")]
35    ChatItemsDeleted(Arc<ChatItemsDeleted>),
36    /// Message events
37    #[serde(rename = "chatItemUpdated")]
38    ChatItemUpdated(Arc<ChatItemUpdated>),
39    /// Message events
40    #[serde(rename = "groupChatItemsDeleted")]
41    GroupChatItemsDeleted(Arc<GroupChatItemsDeleted>),
42    /// Message events
43    #[serde(rename = "chatItemsStatusesUpdated")]
44    ChatItemsStatusesUpdated(Arc<ChatItemsStatusesUpdated>),
45    /// Group events
46    #[serde(rename = "receivedGroupInvitation")]
47    ReceivedGroupInvitation(Arc<ReceivedGroupInvitation>),
48    /// Group events
49    #[serde(rename = "userJoinedGroup")]
50    UserJoinedGroup(Arc<UserJoinedGroup>),
51    /// Group events
52    #[serde(rename = "groupUpdated")]
53    GroupUpdated(Arc<GroupUpdated>),
54    /// Group events
55    #[serde(rename = "joinedGroupMember")]
56    JoinedGroupMember(Arc<JoinedGroupMember>),
57    /// Group events
58    #[serde(rename = "memberRole")]
59    MemberRole(Arc<MemberRole>),
60    /// Group events
61    #[serde(rename = "deletedMember")]
62    DeletedMember(Arc<DeletedMember>),
63    /// Group events
64    #[serde(rename = "leftMember")]
65    LeftMember(Arc<LeftMember>),
66    /// Group events
67    #[serde(rename = "deletedMemberUser")]
68    DeletedMemberUser(Arc<DeletedMemberUser>),
69    /// Group events
70    #[serde(rename = "groupDeleted")]
71    GroupDeleted(Arc<GroupDeleted>),
72    /// Group events
73    #[serde(rename = "connectedToGroupMember")]
74    ConnectedToGroupMember(Arc<ConnectedToGroupMember>),
75    /// Group events
76    #[serde(rename = "memberAcceptedByOther")]
77    MemberAcceptedByOther(Arc<MemberAcceptedByOther>),
78    /// Group events
79    #[serde(rename = "memberBlockedForAll")]
80    MemberBlockedForAll(Arc<MemberBlockedForAll>),
81    /// Group events
82    #[serde(rename = "groupMemberUpdated")]
83    GroupMemberUpdated(Arc<GroupMemberUpdated>),
84    /// Group events
85    #[serde(rename = "groupLinkDataUpdated")]
86    GroupLinkDataUpdated(Arc<GroupLinkDataUpdated>),
87    /// Group events
88    #[serde(rename = "groupRelayUpdated")]
89    GroupRelayUpdated(Arc<GroupRelayUpdated>),
90    /// File events
91    #[serde(rename = "rcvFileDescrReady")]
92    RcvFileDescrReady(Arc<RcvFileDescrReady>),
93    /// File events
94    #[serde(rename = "rcvFileComplete")]
95    RcvFileComplete(Arc<RcvFileComplete>),
96    /// File events
97    #[serde(rename = "sndFileCompleteXFTP")]
98    SndFileCompleteXftp(Arc<SndFileCompleteXftp>),
99    /// File events
100    #[serde(rename = "rcvFileStart")]
101    RcvFileStart(Arc<RcvFileStart>),
102    /// File events
103    #[serde(rename = "rcvFileSndCancelled")]
104    RcvFileSndCancelled(Arc<RcvFileSndCancelled>),
105    /// File events
106    #[serde(rename = "rcvFileAccepted")]
107    RcvFileAccepted(Arc<RcvFileAccepted>),
108    /// File events
109    #[serde(rename = "rcvFileError")]
110    RcvFileError(Arc<RcvFileError>),
111    /// File events
112    #[serde(rename = "rcvFileWarning")]
113    RcvFileWarning(Arc<RcvFileWarning>),
114    /// File events
115    #[serde(rename = "sndFileError")]
116    SndFileError(Arc<SndFileError>),
117    /// File events
118    #[serde(rename = "sndFileWarning")]
119    SndFileWarning(Arc<SndFileWarning>),
120    /// Connection progress events
121    #[serde(rename = "acceptingContactRequest")]
122    AcceptingContactRequest(Arc<AcceptingContactRequest>),
123    /// Connection progress events
124    #[serde(rename = "acceptingBusinessRequest")]
125    AcceptingBusinessRequest(Arc<AcceptingBusinessRequest>),
126    /// Connection progress events
127    #[serde(rename = "contactConnecting")]
128    ContactConnecting(Arc<ContactConnecting>),
129    /// Connection progress events
130    #[serde(rename = "businessLinkConnecting")]
131    BusinessLinkConnecting(Arc<BusinessLinkConnecting>),
132    /// Connection progress events
133    #[serde(rename = "joinedGroupMemberConnecting")]
134    JoinedGroupMemberConnecting(Arc<JoinedGroupMemberConnecting>),
135    /// Connection progress events
136    #[serde(rename = "sentGroupInvitation")]
137    SentGroupInvitation(Arc<SentGroupInvitation>),
138    /// Connection progress events
139    #[serde(rename = "groupLinkConnecting")]
140    GroupLinkConnecting(Arc<GroupLinkConnecting>),
141    /// Network connection events
142    #[serde(rename = "hostConnected")]
143    HostConnected(Arc<HostConnected>),
144    /// Network connection events
145    #[serde(rename = "hostDisconnected")]
146    HostDisconnected(Arc<HostDisconnected>),
147    /// Network connection events
148    #[serde(rename = "subscriptionStatus")]
149    SubscriptionStatus(Arc<SubscriptionStatus>),
150    /// Error events
151    #[serde(rename = "messageError")]
152    MessageError(Arc<MessageError>),
153    /// Error events
154    #[serde(rename = "chatError")]
155    ChatError(Arc<ChatError>),
156    /// Error events
157    #[serde(rename = "chatErrors")]
158    ChatErrors(Arc<ChatErrors>),
159    #[serde(untagged)]
160    Undocumented(JsonObject),
161}
162
163impl Event {
164    pub fn user_id(&self) -> Option<i64> {
165        match self {
166            Self::ContactConnected(_ev) => Some(_ev.user.user_id),
167            Self::ContactUpdated(_ev) => Some(_ev.user.user_id),
168            Self::ContactDeletedByContact(_ev) => Some(_ev.user.user_id),
169            Self::ReceivedContactRequest(_ev) => Some(_ev.user.user_id),
170            Self::NewMemberContactReceivedInv(_ev) => Some(_ev.user.user_id),
171            Self::ContactSndReady(_ev) => Some(_ev.user.user_id),
172            Self::NewChatItems(_ev) => Some(_ev.user.user_id),
173            Self::ChatItemReaction(_ev) => Some(_ev.user.user_id),
174            Self::ChatItemsDeleted(_ev) => Some(_ev.user.user_id),
175            Self::ChatItemUpdated(_ev) => Some(_ev.user.user_id),
176            Self::GroupChatItemsDeleted(_ev) => Some(_ev.user.user_id),
177            Self::ChatItemsStatusesUpdated(_ev) => Some(_ev.user.user_id),
178            Self::ReceivedGroupInvitation(_ev) => Some(_ev.user.user_id),
179            Self::UserJoinedGroup(_ev) => Some(_ev.user.user_id),
180            Self::GroupUpdated(_ev) => Some(_ev.user.user_id),
181            Self::JoinedGroupMember(_ev) => Some(_ev.user.user_id),
182            Self::MemberRole(_ev) => Some(_ev.user.user_id),
183            Self::DeletedMember(_ev) => Some(_ev.user.user_id),
184            Self::LeftMember(_ev) => Some(_ev.user.user_id),
185            Self::DeletedMemberUser(_ev) => Some(_ev.user.user_id),
186            Self::GroupDeleted(_ev) => Some(_ev.user.user_id),
187            Self::ConnectedToGroupMember(_ev) => Some(_ev.user.user_id),
188            Self::MemberAcceptedByOther(_ev) => Some(_ev.user.user_id),
189            Self::MemberBlockedForAll(_ev) => Some(_ev.user.user_id),
190            Self::GroupMemberUpdated(_ev) => Some(_ev.user.user_id),
191            Self::GroupLinkDataUpdated(_ev) => Some(_ev.user.user_id),
192            Self::GroupRelayUpdated(_ev) => Some(_ev.user.user_id),
193            Self::RcvFileDescrReady(_ev) => Some(_ev.user.user_id),
194            Self::RcvFileComplete(_ev) => Some(_ev.user.user_id),
195            Self::SndFileCompleteXftp(_ev) => Some(_ev.user.user_id),
196            Self::RcvFileStart(_ev) => Some(_ev.user.user_id),
197            Self::RcvFileSndCancelled(_ev) => Some(_ev.user.user_id),
198            Self::RcvFileAccepted(_ev) => Some(_ev.user.user_id),
199            Self::RcvFileError(_ev) => Some(_ev.user.user_id),
200            Self::RcvFileWarning(_ev) => Some(_ev.user.user_id),
201            Self::SndFileError(_ev) => Some(_ev.user.user_id),
202            Self::SndFileWarning(_ev) => Some(_ev.user.user_id),
203            Self::AcceptingContactRequest(_ev) => Some(_ev.user.user_id),
204            Self::AcceptingBusinessRequest(_ev) => Some(_ev.user.user_id),
205            Self::ContactConnecting(_ev) => Some(_ev.user.user_id),
206            Self::BusinessLinkConnecting(_ev) => Some(_ev.user.user_id),
207            Self::JoinedGroupMemberConnecting(_ev) => Some(_ev.user.user_id),
208            Self::SentGroupInvitation(_ev) => Some(_ev.user.user_id),
209            Self::GroupLinkConnecting(_ev) => Some(_ev.user.user_id),
210            Self::HostConnected(_ev) => None,
211            Self::HostDisconnected(_ev) => None,
212            Self::SubscriptionStatus(_ev) => None,
213            Self::MessageError(_ev) => Some(_ev.user.user_id),
214            Self::ChatError(_ev) => None,
215            Self::ChatErrors(_ev) => None,
216            Self::Undocumented(_) => None,
217        }
218    }
219}
220
221impl Event {
222    pub fn kind(&self) -> EventKind {
223        match self {
224            Self::ContactConnected(_) => EventKind::ContactConnected,
225            Self::ContactUpdated(_) => EventKind::ContactUpdated,
226            Self::ContactDeletedByContact(_) => EventKind::ContactDeletedByContact,
227            Self::ReceivedContactRequest(_) => EventKind::ReceivedContactRequest,
228            Self::NewMemberContactReceivedInv(_) => EventKind::NewMemberContactReceivedInv,
229            Self::ContactSndReady(_) => EventKind::ContactSndReady,
230            Self::NewChatItems(_) => EventKind::NewChatItems,
231            Self::ChatItemReaction(_) => EventKind::ChatItemReaction,
232            Self::ChatItemsDeleted(_) => EventKind::ChatItemsDeleted,
233            Self::ChatItemUpdated(_) => EventKind::ChatItemUpdated,
234            Self::GroupChatItemsDeleted(_) => EventKind::GroupChatItemsDeleted,
235            Self::ChatItemsStatusesUpdated(_) => EventKind::ChatItemsStatusesUpdated,
236            Self::ReceivedGroupInvitation(_) => EventKind::ReceivedGroupInvitation,
237            Self::UserJoinedGroup(_) => EventKind::UserJoinedGroup,
238            Self::GroupUpdated(_) => EventKind::GroupUpdated,
239            Self::JoinedGroupMember(_) => EventKind::JoinedGroupMember,
240            Self::MemberRole(_) => EventKind::MemberRole,
241            Self::DeletedMember(_) => EventKind::DeletedMember,
242            Self::LeftMember(_) => EventKind::LeftMember,
243            Self::DeletedMemberUser(_) => EventKind::DeletedMemberUser,
244            Self::GroupDeleted(_) => EventKind::GroupDeleted,
245            Self::ConnectedToGroupMember(_) => EventKind::ConnectedToGroupMember,
246            Self::MemberAcceptedByOther(_) => EventKind::MemberAcceptedByOther,
247            Self::MemberBlockedForAll(_) => EventKind::MemberBlockedForAll,
248            Self::GroupMemberUpdated(_) => EventKind::GroupMemberUpdated,
249            Self::GroupLinkDataUpdated(_) => EventKind::GroupLinkDataUpdated,
250            Self::GroupRelayUpdated(_) => EventKind::GroupRelayUpdated,
251            Self::RcvFileDescrReady(_) => EventKind::RcvFileDescrReady,
252            Self::RcvFileComplete(_) => EventKind::RcvFileComplete,
253            Self::SndFileCompleteXftp(_) => EventKind::SndFileCompleteXftp,
254            Self::RcvFileStart(_) => EventKind::RcvFileStart,
255            Self::RcvFileSndCancelled(_) => EventKind::RcvFileSndCancelled,
256            Self::RcvFileAccepted(_) => EventKind::RcvFileAccepted,
257            Self::RcvFileError(_) => EventKind::RcvFileError,
258            Self::RcvFileWarning(_) => EventKind::RcvFileWarning,
259            Self::SndFileError(_) => EventKind::SndFileError,
260            Self::SndFileWarning(_) => EventKind::SndFileWarning,
261            Self::AcceptingContactRequest(_) => EventKind::AcceptingContactRequest,
262            Self::AcceptingBusinessRequest(_) => EventKind::AcceptingBusinessRequest,
263            Self::ContactConnecting(_) => EventKind::ContactConnecting,
264            Self::BusinessLinkConnecting(_) => EventKind::BusinessLinkConnecting,
265            Self::JoinedGroupMemberConnecting(_) => EventKind::JoinedGroupMemberConnecting,
266            Self::SentGroupInvitation(_) => EventKind::SentGroupInvitation,
267            Self::GroupLinkConnecting(_) => EventKind::GroupLinkConnecting,
268            Self::HostConnected(_) => EventKind::HostConnected,
269            Self::HostDisconnected(_) => EventKind::HostDisconnected,
270            Self::SubscriptionStatus(_) => EventKind::SubscriptionStatus,
271            Self::MessageError(_) => EventKind::MessageError,
272            Self::ChatError(_) => EventKind::ChatError,
273            Self::ChatErrors(_) => EventKind::ChatErrors,
274            Self::Undocumented(_) => EventKind::Undocumented,
275        }
276    }
277}
278#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
279#[non_exhaustive]
280pub enum EventKind {
281    ContactConnected,
282    ContactUpdated,
283    ContactDeletedByContact,
284    ReceivedContactRequest,
285    NewMemberContactReceivedInv,
286    ContactSndReady,
287    NewChatItems,
288    ChatItemReaction,
289    ChatItemsDeleted,
290    ChatItemUpdated,
291    GroupChatItemsDeleted,
292    ChatItemsStatusesUpdated,
293    ReceivedGroupInvitation,
294    UserJoinedGroup,
295    GroupUpdated,
296    JoinedGroupMember,
297    MemberRole,
298    DeletedMember,
299    LeftMember,
300    DeletedMemberUser,
301    GroupDeleted,
302    ConnectedToGroupMember,
303    MemberAcceptedByOther,
304    MemberBlockedForAll,
305    GroupMemberUpdated,
306    GroupLinkDataUpdated,
307    GroupRelayUpdated,
308    RcvFileDescrReady,
309    RcvFileComplete,
310    SndFileCompleteXftp,
311    RcvFileStart,
312    RcvFileSndCancelled,
313    RcvFileAccepted,
314    RcvFileError,
315    RcvFileWarning,
316    SndFileError,
317    SndFileWarning,
318    AcceptingContactRequest,
319    AcceptingBusinessRequest,
320    ContactConnecting,
321    BusinessLinkConnecting,
322    JoinedGroupMemberConnecting,
323    SentGroupInvitation,
324    GroupLinkConnecting,
325    HostConnected,
326    HostDisconnected,
327    SubscriptionStatus,
328    MessageError,
329    ChatError,
330    ChatErrors,
331    Undocumented,
332}
333
334impl EventKind {
335    pub const COUNT: usize = 51;
336
337    pub fn as_usize(&self) -> usize {
338        match self {
339            Self::ContactConnected => 0,
340            Self::ContactUpdated => 1,
341            Self::ContactDeletedByContact => 2,
342            Self::ReceivedContactRequest => 3,
343            Self::NewMemberContactReceivedInv => 4,
344            Self::ContactSndReady => 5,
345            Self::NewChatItems => 6,
346            Self::ChatItemReaction => 7,
347            Self::ChatItemsDeleted => 8,
348            Self::ChatItemUpdated => 9,
349            Self::GroupChatItemsDeleted => 10,
350            Self::ChatItemsStatusesUpdated => 11,
351            Self::ReceivedGroupInvitation => 12,
352            Self::UserJoinedGroup => 13,
353            Self::GroupUpdated => 14,
354            Self::JoinedGroupMember => 15,
355            Self::MemberRole => 16,
356            Self::DeletedMember => 17,
357            Self::LeftMember => 18,
358            Self::DeletedMemberUser => 19,
359            Self::GroupDeleted => 20,
360            Self::ConnectedToGroupMember => 21,
361            Self::MemberAcceptedByOther => 22,
362            Self::MemberBlockedForAll => 23,
363            Self::GroupMemberUpdated => 24,
364            Self::GroupLinkDataUpdated => 25,
365            Self::GroupRelayUpdated => 26,
366            Self::RcvFileDescrReady => 27,
367            Self::RcvFileComplete => 28,
368            Self::SndFileCompleteXftp => 29,
369            Self::RcvFileStart => 30,
370            Self::RcvFileSndCancelled => 31,
371            Self::RcvFileAccepted => 32,
372            Self::RcvFileError => 33,
373            Self::RcvFileWarning => 34,
374            Self::SndFileError => 35,
375            Self::SndFileWarning => 36,
376            Self::AcceptingContactRequest => 37,
377            Self::AcceptingBusinessRequest => 38,
378            Self::ContactConnecting => 39,
379            Self::BusinessLinkConnecting => 40,
380            Self::JoinedGroupMemberConnecting => 41,
381            Self::SentGroupInvitation => 42,
382            Self::GroupLinkConnecting => 43,
383            Self::HostConnected => 44,
384            Self::HostDisconnected => 45,
385            Self::SubscriptionStatus => 46,
386            Self::MessageError => 47,
387            Self::ChatError => 48,
388            Self::ChatErrors => 49,
389            Self::Undocumented => 50,
390        }
391    }
392    pub fn from_type_str(type_str: &str) -> Self {
393        match type_str {
394            "contactConnected" => Self::ContactConnected,
395            "contactUpdated" => Self::ContactUpdated,
396            "contactDeletedByContact" => Self::ContactDeletedByContact,
397            "receivedContactRequest" => Self::ReceivedContactRequest,
398            "newMemberContactReceivedInv" => Self::NewMemberContactReceivedInv,
399            "contactSndReady" => Self::ContactSndReady,
400            "newChatItems" => Self::NewChatItems,
401            "chatItemReaction" => Self::ChatItemReaction,
402            "chatItemsDeleted" => Self::ChatItemsDeleted,
403            "chatItemUpdated" => Self::ChatItemUpdated,
404            "groupChatItemsDeleted" => Self::GroupChatItemsDeleted,
405            "chatItemsStatusesUpdated" => Self::ChatItemsStatusesUpdated,
406            "receivedGroupInvitation" => Self::ReceivedGroupInvitation,
407            "userJoinedGroup" => Self::UserJoinedGroup,
408            "groupUpdated" => Self::GroupUpdated,
409            "joinedGroupMember" => Self::JoinedGroupMember,
410            "memberRole" => Self::MemberRole,
411            "deletedMember" => Self::DeletedMember,
412            "leftMember" => Self::LeftMember,
413            "deletedMemberUser" => Self::DeletedMemberUser,
414            "groupDeleted" => Self::GroupDeleted,
415            "connectedToGroupMember" => Self::ConnectedToGroupMember,
416            "memberAcceptedByOther" => Self::MemberAcceptedByOther,
417            "memberBlockedForAll" => Self::MemberBlockedForAll,
418            "groupMemberUpdated" => Self::GroupMemberUpdated,
419            "groupLinkDataUpdated" => Self::GroupLinkDataUpdated,
420            "groupRelayUpdated" => Self::GroupRelayUpdated,
421            "rcvFileDescrReady" => Self::RcvFileDescrReady,
422            "rcvFileComplete" => Self::RcvFileComplete,
423            "sndFileCompleteXFTP" => Self::SndFileCompleteXftp,
424            "rcvFileStart" => Self::RcvFileStart,
425            "rcvFileSndCancelled" => Self::RcvFileSndCancelled,
426            "rcvFileAccepted" => Self::RcvFileAccepted,
427            "rcvFileError" => Self::RcvFileError,
428            "rcvFileWarning" => Self::RcvFileWarning,
429            "sndFileError" => Self::SndFileError,
430            "sndFileWarning" => Self::SndFileWarning,
431            "acceptingContactRequest" => Self::AcceptingContactRequest,
432            "acceptingBusinessRequest" => Self::AcceptingBusinessRequest,
433            "contactConnecting" => Self::ContactConnecting,
434            "businessLinkConnecting" => Self::BusinessLinkConnecting,
435            "joinedGroupMemberConnecting" => Self::JoinedGroupMemberConnecting,
436            "sentGroupInvitation" => Self::SentGroupInvitation,
437            "groupLinkConnecting" => Self::GroupLinkConnecting,
438            "hostConnected" => Self::HostConnected,
439            "hostDisconnected" => Self::HostDisconnected,
440            "subscriptionStatus" => Self::SubscriptionStatus,
441            "messageError" => Self::MessageError,
442            "chatError" => Self::ChatError,
443            "chatErrors" => Self::ChatErrors,
444            _ => Self::Undocumented,
445        }
446    }
447}
448
449/// Generalization of event data
450pub trait EventData {
451    const KIND: EventKind;
452
453    fn from_event(event: Event) -> Result<Arc<Self>, Event>;
454
455    fn into_event(self: Arc<Self>) -> Event;
456}
457
458/// ### Contact connection events
459///
460/// Bots must use these events to process connecting users.
461///
462/// Most bots enable auto-accept and don't need to accept connections via commands.
463///
464/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
465/// - [ApiShowMyAddress] to check if address exists,
466/// - [ApiCreateMyAddress] to create address,
467/// - [ApiSetAddressSettings] to enable auto-access.
468///
469/// ----
470///
471/// This event is sent after a user connects via bot SimpleX address (not a business address).
472#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
473#[cfg_attr(feature = "bon", derive(::bon::Builder))]
474#[cfg_attr(feature = "bon", builder(on(String, into)))]
475pub struct ContactConnected {
476    #[serde(rename = "user")]
477    pub user: crate::User,
478
479    #[serde(rename = "contact")]
480    pub contact: crate::Contact,
481
482    #[serde(rename = "userCustomProfile", skip_serializing_if = "Option::is_none")]
483    pub user_custom_profile: Option<crate::Profile>,
484
485    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
486    #[cfg_attr(feature = "bon", builder(default))]
487    pub undocumented: JsonObject,
488}
489
490impl EventData for ContactConnected {
491    const KIND: EventKind = EventKind::ContactConnected;
492    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
493        if let Event::ContactConnected(data) = ev {
494            Ok(data)
495        } else {
496            Err(ev)
497        }
498    }
499    fn into_event(self: Arc<Self>) -> Event {
500        Event::ContactConnected(self)
501    }
502}
503
504/// ### Contact connection events
505///
506/// Bots must use these events to process connecting users.
507///
508/// Most bots enable auto-accept and don't need to accept connections via commands.
509///
510/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
511/// - [ApiShowMyAddress] to check if address exists,
512/// - [ApiCreateMyAddress] to create address,
513/// - [ApiSetAddressSettings] to enable auto-access.
514///
515/// ----
516///
517/// Contact profile of another user is updated.
518#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
519#[cfg_attr(feature = "bon", derive(::bon::Builder))]
520#[cfg_attr(feature = "bon", builder(on(String, into)))]
521pub struct ContactUpdated {
522    #[serde(rename = "user")]
523    pub user: crate::User,
524
525    #[serde(rename = "fromContact")]
526    pub from_contact: crate::Contact,
527
528    #[serde(rename = "toContact")]
529    pub to_contact: crate::Contact,
530
531    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
532    #[cfg_attr(feature = "bon", builder(default))]
533    pub undocumented: JsonObject,
534}
535
536impl EventData for ContactUpdated {
537    const KIND: EventKind = EventKind::ContactUpdated;
538    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
539        if let Event::ContactUpdated(data) = ev {
540            Ok(data)
541        } else {
542            Err(ev)
543        }
544    }
545    fn into_event(self: Arc<Self>) -> Event {
546        Event::ContactUpdated(self)
547    }
548}
549
550/// ### Contact connection events
551///
552/// Bots must use these events to process connecting users.
553///
554/// Most bots enable auto-accept and don't need to accept connections via commands.
555///
556/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
557/// - [ApiShowMyAddress] to check if address exists,
558/// - [ApiCreateMyAddress] to create address,
559/// - [ApiSetAddressSettings] to enable auto-access.
560///
561/// ----
562///
563/// Bot user's connection with another contact is deleted (conversation is kept).
564#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
565#[cfg_attr(feature = "bon", derive(::bon::Builder))]
566#[cfg_attr(feature = "bon", builder(on(String, into)))]
567pub struct ContactDeletedByContact {
568    #[serde(rename = "user")]
569    pub user: crate::User,
570
571    #[serde(rename = "contact")]
572    pub contact: crate::Contact,
573
574    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
575    #[cfg_attr(feature = "bon", builder(default))]
576    pub undocumented: JsonObject,
577}
578
579impl EventData for ContactDeletedByContact {
580    const KIND: EventKind = EventKind::ContactDeletedByContact;
581    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
582        if let Event::ContactDeletedByContact(data) = ev {
583            Ok(data)
584        } else {
585            Err(ev)
586        }
587    }
588    fn into_event(self: Arc<Self>) -> Event {
589        Event::ContactDeletedByContact(self)
590    }
591}
592
593/// ### Contact connection events
594///
595/// Bots must use these events to process connecting users.
596///
597/// Most bots enable auto-accept and don't need to accept connections via commands.
598///
599/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
600/// - [ApiShowMyAddress] to check if address exists,
601/// - [ApiCreateMyAddress] to create address,
602/// - [ApiSetAddressSettings] to enable auto-access.
603///
604/// ----
605///
606/// Contact request received.
607///
608/// This event is only sent when auto-accept is disabled.
609///
610/// The request needs to be accepted using [ApiAcceptContact] command
611#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
612#[cfg_attr(feature = "bon", derive(::bon::Builder))]
613#[cfg_attr(feature = "bon", builder(on(String, into)))]
614pub struct ReceivedContactRequest {
615    #[serde(rename = "user")]
616    pub user: crate::User,
617
618    #[serde(rename = "contactRequest")]
619    pub contact_request: crate::UserContactRequest,
620
621    #[serde(rename = "chat_", skip_serializing_if = "Option::is_none")]
622    pub chat: Option<crate::AChat>,
623
624    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
625    #[cfg_attr(feature = "bon", builder(default))]
626    pub undocumented: JsonObject,
627}
628
629impl EventData for ReceivedContactRequest {
630    const KIND: EventKind = EventKind::ReceivedContactRequest;
631    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
632        if let Event::ReceivedContactRequest(data) = ev {
633            Ok(data)
634        } else {
635            Err(ev)
636        }
637    }
638    fn into_event(self: Arc<Self>) -> Event {
639        Event::ReceivedContactRequest(self)
640    }
641}
642
643/// ### Contact connection events
644///
645/// Bots must use these events to process connecting users.
646///
647/// Most bots enable auto-accept and don't need to accept connections via commands.
648///
649/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
650/// - [ApiShowMyAddress] to check if address exists,
651/// - [ApiCreateMyAddress] to create address,
652/// - [ApiSetAddressSettings] to enable auto-access.
653///
654/// ----
655///
656/// Received invitation to connect directly with a group member.
657///
658/// This event only needs to be processed to associate contact with group, the connection will proceed automatically.
659#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
660#[cfg_attr(feature = "bon", derive(::bon::Builder))]
661#[cfg_attr(feature = "bon", builder(on(String, into)))]
662pub struct NewMemberContactReceivedInv {
663    #[serde(rename = "user")]
664    pub user: crate::User,
665
666    #[serde(rename = "contact")]
667    pub contact: crate::Contact,
668
669    #[serde(rename = "groupInfo")]
670    pub group_info: crate::GroupInfo,
671
672    #[serde(rename = "member")]
673    pub member: crate::GroupMember,
674
675    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
676    #[cfg_attr(feature = "bon", builder(default))]
677    pub undocumented: JsonObject,
678}
679
680impl EventData for NewMemberContactReceivedInv {
681    const KIND: EventKind = EventKind::NewMemberContactReceivedInv;
682    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
683        if let Event::NewMemberContactReceivedInv(data) = ev {
684            Ok(data)
685        } else {
686            Err(ev)
687        }
688    }
689    fn into_event(self: Arc<Self>) -> Event {
690        Event::NewMemberContactReceivedInv(self)
691    }
692}
693
694/// ### Contact connection events
695///
696/// Bots must use these events to process connecting users.
697///
698/// Most bots enable auto-accept and don't need to accept connections via commands.
699///
700/// You may create bot SimpleX address manually via CLI or desktop app or from bot code with these commands:
701/// - [ApiShowMyAddress] to check if address exists,
702/// - [ApiCreateMyAddress] to create address,
703/// - [ApiSetAddressSettings] to enable auto-access.
704///
705/// ----
706///
707/// Connecting via 1-time invitation or after accepting contact request.
708///
709/// After this event bot can send messages to this contact.
710#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
711#[cfg_attr(feature = "bon", derive(::bon::Builder))]
712#[cfg_attr(feature = "bon", builder(on(String, into)))]
713pub struct ContactSndReady {
714    #[serde(rename = "user")]
715    pub user: crate::User,
716
717    #[serde(rename = "contact")]
718    pub contact: crate::Contact,
719
720    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
721    #[cfg_attr(feature = "bon", builder(default))]
722    pub undocumented: JsonObject,
723}
724
725impl EventData for ContactSndReady {
726    const KIND: EventKind = EventKind::ContactSndReady;
727    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
728        if let Event::ContactSndReady(data) = ev {
729            Ok(data)
730        } else {
731            Err(ev)
732        }
733    }
734    fn into_event(self: Arc<Self>) -> Event {
735        Event::ContactSndReady(self)
736    }
737}
738
739/// ### Message events
740///
741/// Bots must use these events to process received messages.
742///
743/// ----
744///
745/// Received message(s).
746#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
747#[cfg_attr(feature = "bon", derive(::bon::Builder))]
748#[cfg_attr(feature = "bon", builder(on(String, into)))]
749pub struct NewChatItems {
750    #[serde(rename = "user")]
751    pub user: crate::User,
752
753    #[serde(rename = "chatItems")]
754    pub chat_items: Vec<crate::AChatItem>,
755
756    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
757    #[cfg_attr(feature = "bon", builder(default))]
758    pub undocumented: JsonObject,
759}
760
761impl EventData for NewChatItems {
762    const KIND: EventKind = EventKind::NewChatItems;
763    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
764        if let Event::NewChatItems(data) = ev {
765            Ok(data)
766        } else {
767            Err(ev)
768        }
769    }
770    fn into_event(self: Arc<Self>) -> Event {
771        Event::NewChatItems(self)
772    }
773}
774
775/// ### Message events
776///
777/// Bots must use these events to process received messages.
778///
779/// ----
780///
781/// Received message reaction.
782#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
783#[cfg_attr(feature = "bon", derive(::bon::Builder))]
784#[cfg_attr(feature = "bon", builder(on(String, into)))]
785pub struct ChatItemReaction {
786    #[serde(rename = "user")]
787    pub user: crate::User,
788
789    #[serde(rename = "added", default)]
790    pub added: bool,
791
792    #[serde(rename = "reaction")]
793    pub reaction: crate::ACIReaction,
794
795    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
796    #[cfg_attr(feature = "bon", builder(default))]
797    pub undocumented: JsonObject,
798}
799
800impl EventData for ChatItemReaction {
801    const KIND: EventKind = EventKind::ChatItemReaction;
802    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
803        if let Event::ChatItemReaction(data) = ev {
804            Ok(data)
805        } else {
806            Err(ev)
807        }
808    }
809    fn into_event(self: Arc<Self>) -> Event {
810        Event::ChatItemReaction(self)
811    }
812}
813
814/// ### Message events
815///
816/// Bots must use these events to process received messages.
817///
818/// ----
819///
820/// Message was deleted by another user.
821#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
822#[cfg_attr(feature = "bon", derive(::bon::Builder))]
823#[cfg_attr(feature = "bon", builder(on(String, into)))]
824pub struct ChatItemsDeleted {
825    #[serde(rename = "user")]
826    pub user: crate::User,
827
828    #[serde(rename = "chatItemDeletions")]
829    pub chat_item_deletions: Vec<crate::ChatItemDeletion>,
830
831    #[serde(rename = "byUser", default)]
832    pub by_user: bool,
833
834    #[serde(rename = "timed", default)]
835    pub timed: bool,
836
837    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
838    #[cfg_attr(feature = "bon", builder(default))]
839    pub undocumented: JsonObject,
840}
841
842impl EventData for ChatItemsDeleted {
843    const KIND: EventKind = EventKind::ChatItemsDeleted;
844    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
845        if let Event::ChatItemsDeleted(data) = ev {
846            Ok(data)
847        } else {
848            Err(ev)
849        }
850    }
851    fn into_event(self: Arc<Self>) -> Event {
852        Event::ChatItemsDeleted(self)
853    }
854}
855
856/// ### Message events
857///
858/// Bots must use these events to process received messages.
859///
860/// ----
861///
862/// Message was updated by another user.
863#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
864#[cfg_attr(feature = "bon", derive(::bon::Builder))]
865#[cfg_attr(feature = "bon", builder(on(String, into)))]
866pub struct ChatItemUpdated {
867    #[serde(rename = "user")]
868    pub user: crate::User,
869
870    #[serde(rename = "chatItem")]
871    pub chat_item: crate::AChatItem,
872
873    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
874    #[cfg_attr(feature = "bon", builder(default))]
875    pub undocumented: JsonObject,
876}
877
878impl EventData for ChatItemUpdated {
879    const KIND: EventKind = EventKind::ChatItemUpdated;
880    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
881        if let Event::ChatItemUpdated(data) = ev {
882            Ok(data)
883        } else {
884            Err(ev)
885        }
886    }
887    fn into_event(self: Arc<Self>) -> Event {
888        Event::ChatItemUpdated(self)
889    }
890}
891
892/// ### Message events
893///
894/// Bots must use these events to process received messages.
895///
896/// ----
897///
898/// Group messages are deleted or moderated.
899#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
900#[cfg_attr(feature = "bon", derive(::bon::Builder))]
901#[cfg_attr(feature = "bon", builder(on(String, into)))]
902pub struct GroupChatItemsDeleted {
903    #[serde(rename = "user")]
904    pub user: crate::User,
905
906    #[serde(rename = "groupInfo")]
907    pub group_info: crate::GroupInfo,
908
909    #[serde(rename = "chatItemIDs")]
910    pub chat_item_i_ds: Vec<i64>,
911
912    #[serde(rename = "byUser", default)]
913    pub by_user: bool,
914
915    #[serde(rename = "member_", skip_serializing_if = "Option::is_none")]
916    pub member: Option<crate::GroupMember>,
917
918    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
919    #[cfg_attr(feature = "bon", builder(default))]
920    pub undocumented: JsonObject,
921}
922
923impl EventData for GroupChatItemsDeleted {
924    const KIND: EventKind = EventKind::GroupChatItemsDeleted;
925    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
926        if let Event::GroupChatItemsDeleted(data) = ev {
927            Ok(data)
928        } else {
929            Err(ev)
930        }
931    }
932    fn into_event(self: Arc<Self>) -> Event {
933        Event::GroupChatItemsDeleted(self)
934    }
935}
936
937/// ### Message events
938///
939/// Bots must use these events to process received messages.
940///
941/// ----
942///
943/// Message delivery status updates.
944#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
945#[cfg_attr(feature = "bon", derive(::bon::Builder))]
946#[cfg_attr(feature = "bon", builder(on(String, into)))]
947pub struct ChatItemsStatusesUpdated {
948    #[serde(rename = "user")]
949    pub user: crate::User,
950
951    #[serde(rename = "chatItems")]
952    pub chat_items: Vec<crate::AChatItem>,
953
954    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
955    #[cfg_attr(feature = "bon", builder(default))]
956    pub undocumented: JsonObject,
957}
958
959impl EventData for ChatItemsStatusesUpdated {
960    const KIND: EventKind = EventKind::ChatItemsStatusesUpdated;
961    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
962        if let Event::ChatItemsStatusesUpdated(data) = ev {
963            Ok(data)
964        } else {
965            Err(ev)
966        }
967    }
968    fn into_event(self: Arc<Self>) -> Event {
969        Event::ChatItemsStatusesUpdated(self)
970    }
971}
972
973/// ### Group events
974///
975/// Bots may use these events to manage users' groups and business address groups.
976///
977/// *Please note*: programming groups is more complex than programming direct connections
978///
979/// ----
980///
981/// Received group invitation.
982#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
983#[cfg_attr(feature = "bon", derive(::bon::Builder))]
984#[cfg_attr(feature = "bon", builder(on(String, into)))]
985pub struct ReceivedGroupInvitation {
986    #[serde(rename = "user")]
987    pub user: crate::User,
988
989    #[serde(rename = "groupInfo")]
990    pub group_info: crate::GroupInfo,
991
992    #[serde(rename = "contact")]
993    pub contact: crate::Contact,
994
995    #[serde(rename = "fromMemberRole")]
996    pub from_member_role: crate::GroupMemberRole,
997
998    #[serde(rename = "memberRole")]
999    pub member_role: crate::GroupMemberRole,
1000
1001    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1002    #[cfg_attr(feature = "bon", builder(default))]
1003    pub undocumented: JsonObject,
1004}
1005
1006impl EventData for ReceivedGroupInvitation {
1007    const KIND: EventKind = EventKind::ReceivedGroupInvitation;
1008    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1009        if let Event::ReceivedGroupInvitation(data) = ev {
1010            Ok(data)
1011        } else {
1012            Err(ev)
1013        }
1014    }
1015    fn into_event(self: Arc<Self>) -> Event {
1016        Event::ReceivedGroupInvitation(self)
1017    }
1018}
1019
1020/// ### Group events
1021///
1022/// Bots may use these events to manage users' groups and business address groups.
1023///
1024/// *Please note*: programming groups is more complex than programming direct connections
1025///
1026/// ----
1027///
1028/// Bot user joined group. Received when connection via group link completes.
1029#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1030#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1031#[cfg_attr(feature = "bon", builder(on(String, into)))]
1032pub struct UserJoinedGroup {
1033    #[serde(rename = "user")]
1034    pub user: crate::User,
1035
1036    #[serde(rename = "groupInfo")]
1037    pub group_info: crate::GroupInfo,
1038
1039    #[serde(rename = "hostMember")]
1040    pub host_member: crate::GroupMember,
1041
1042    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1043    #[cfg_attr(feature = "bon", builder(default))]
1044    pub undocumented: JsonObject,
1045}
1046
1047impl EventData for UserJoinedGroup {
1048    const KIND: EventKind = EventKind::UserJoinedGroup;
1049    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1050        if let Event::UserJoinedGroup(data) = ev {
1051            Ok(data)
1052        } else {
1053            Err(ev)
1054        }
1055    }
1056    fn into_event(self: Arc<Self>) -> Event {
1057        Event::UserJoinedGroup(self)
1058    }
1059}
1060
1061/// ### Group events
1062///
1063/// Bots may use these events to manage users' groups and business address groups.
1064///
1065/// *Please note*: programming groups is more complex than programming direct connections
1066///
1067/// ----
1068///
1069/// Group profile or preferences updated.
1070#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1071#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1072#[cfg_attr(feature = "bon", builder(on(String, into)))]
1073pub struct GroupUpdated {
1074    #[serde(rename = "user")]
1075    pub user: crate::User,
1076
1077    #[serde(rename = "fromGroup")]
1078    pub from_group: crate::GroupInfo,
1079
1080    #[serde(rename = "toGroup")]
1081    pub to_group: crate::GroupInfo,
1082
1083    #[serde(rename = "member_", skip_serializing_if = "Option::is_none")]
1084    pub member: Option<crate::GroupMember>,
1085
1086    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1087    pub msg_signed: Option<crate::MsgSigStatus>,
1088
1089    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1090    #[cfg_attr(feature = "bon", builder(default))]
1091    pub undocumented: JsonObject,
1092}
1093
1094impl EventData for GroupUpdated {
1095    const KIND: EventKind = EventKind::GroupUpdated;
1096    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1097        if let Event::GroupUpdated(data) = ev {
1098            Ok(data)
1099        } else {
1100            Err(ev)
1101        }
1102    }
1103    fn into_event(self: Arc<Self>) -> Event {
1104        Event::GroupUpdated(self)
1105    }
1106}
1107
1108/// ### Group events
1109///
1110/// Bots may use these events to manage users' groups and business address groups.
1111///
1112/// *Please note*: programming groups is more complex than programming direct connections
1113///
1114/// ----
1115///
1116/// Another member joined group.
1117#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1118#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1119#[cfg_attr(feature = "bon", builder(on(String, into)))]
1120pub struct JoinedGroupMember {
1121    #[serde(rename = "user")]
1122    pub user: crate::User,
1123
1124    #[serde(rename = "groupInfo")]
1125    pub group_info: crate::GroupInfo,
1126
1127    #[serde(rename = "member")]
1128    pub member: crate::GroupMember,
1129
1130    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1131    #[cfg_attr(feature = "bon", builder(default))]
1132    pub undocumented: JsonObject,
1133}
1134
1135impl EventData for JoinedGroupMember {
1136    const KIND: EventKind = EventKind::JoinedGroupMember;
1137    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1138        if let Event::JoinedGroupMember(data) = ev {
1139            Ok(data)
1140        } else {
1141            Err(ev)
1142        }
1143    }
1144    fn into_event(self: Arc<Self>) -> Event {
1145        Event::JoinedGroupMember(self)
1146    }
1147}
1148
1149/// ### Group events
1150///
1151/// Bots may use these events to manage users' groups and business address groups.
1152///
1153/// *Please note*: programming groups is more complex than programming direct connections
1154///
1155/// ----
1156///
1157/// Member (or bot user's) group role changed.
1158#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1159#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1160#[cfg_attr(feature = "bon", builder(on(String, into)))]
1161pub struct MemberRole {
1162    #[serde(rename = "user")]
1163    pub user: crate::User,
1164
1165    #[serde(rename = "groupInfo")]
1166    pub group_info: crate::GroupInfo,
1167
1168    #[serde(rename = "byMember")]
1169    pub by_member: crate::GroupMember,
1170
1171    #[serde(rename = "member")]
1172    pub member: crate::GroupMember,
1173
1174    #[serde(rename = "fromRole")]
1175    pub from_role: crate::GroupMemberRole,
1176
1177    #[serde(rename = "toRole")]
1178    pub to_role: crate::GroupMemberRole,
1179
1180    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1181    pub msg_signed: Option<crate::MsgSigStatus>,
1182
1183    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1184    #[cfg_attr(feature = "bon", builder(default))]
1185    pub undocumented: JsonObject,
1186}
1187
1188impl EventData for MemberRole {
1189    const KIND: EventKind = EventKind::MemberRole;
1190    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1191        if let Event::MemberRole(data) = ev {
1192            Ok(data)
1193        } else {
1194            Err(ev)
1195        }
1196    }
1197    fn into_event(self: Arc<Self>) -> Event {
1198        Event::MemberRole(self)
1199    }
1200}
1201
1202/// ### Group events
1203///
1204/// Bots may use these events to manage users' groups and business address groups.
1205///
1206/// *Please note*: programming groups is more complex than programming direct connections
1207///
1208/// ----
1209///
1210/// Another member is removed from the group.
1211#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1212#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1213#[cfg_attr(feature = "bon", builder(on(String, into)))]
1214pub struct DeletedMember {
1215    #[serde(rename = "user")]
1216    pub user: crate::User,
1217
1218    #[serde(rename = "groupInfo")]
1219    pub group_info: crate::GroupInfo,
1220
1221    #[serde(rename = "byMember")]
1222    pub by_member: crate::GroupMember,
1223
1224    #[serde(rename = "deletedMember")]
1225    pub deleted_member: crate::GroupMember,
1226
1227    #[serde(rename = "withMessages", default)]
1228    pub with_messages: bool,
1229
1230    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1231    pub msg_signed: Option<crate::MsgSigStatus>,
1232
1233    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1234    #[cfg_attr(feature = "bon", builder(default))]
1235    pub undocumented: JsonObject,
1236}
1237
1238impl EventData for DeletedMember {
1239    const KIND: EventKind = EventKind::DeletedMember;
1240    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1241        if let Event::DeletedMember(data) = ev {
1242            Ok(data)
1243        } else {
1244            Err(ev)
1245        }
1246    }
1247    fn into_event(self: Arc<Self>) -> Event {
1248        Event::DeletedMember(self)
1249    }
1250}
1251
1252/// ### Group events
1253///
1254/// Bots may use these events to manage users' groups and business address groups.
1255///
1256/// *Please note*: programming groups is more complex than programming direct connections
1257///
1258/// ----
1259///
1260/// Another member left the group.
1261#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1262#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1263#[cfg_attr(feature = "bon", builder(on(String, into)))]
1264pub struct LeftMember {
1265    #[serde(rename = "user")]
1266    pub user: crate::User,
1267
1268    #[serde(rename = "groupInfo")]
1269    pub group_info: crate::GroupInfo,
1270
1271    #[serde(rename = "member")]
1272    pub member: crate::GroupMember,
1273
1274    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1275    pub msg_signed: Option<crate::MsgSigStatus>,
1276
1277    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1278    #[cfg_attr(feature = "bon", builder(default))]
1279    pub undocumented: JsonObject,
1280}
1281
1282impl EventData for LeftMember {
1283    const KIND: EventKind = EventKind::LeftMember;
1284    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1285        if let Event::LeftMember(data) = ev {
1286            Ok(data)
1287        } else {
1288            Err(ev)
1289        }
1290    }
1291    fn into_event(self: Arc<Self>) -> Event {
1292        Event::LeftMember(self)
1293    }
1294}
1295
1296/// ### Group events
1297///
1298/// Bots may use these events to manage users' groups and business address groups.
1299///
1300/// *Please note*: programming groups is more complex than programming direct connections
1301///
1302/// ----
1303///
1304/// Bot user was removed from the group.
1305#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1306#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1307#[cfg_attr(feature = "bon", builder(on(String, into)))]
1308pub struct DeletedMemberUser {
1309    #[serde(rename = "user")]
1310    pub user: crate::User,
1311
1312    #[serde(rename = "groupInfo")]
1313    pub group_info: crate::GroupInfo,
1314
1315    #[serde(rename = "member")]
1316    pub member: crate::GroupMember,
1317
1318    #[serde(rename = "withMessages", default)]
1319    pub with_messages: bool,
1320
1321    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1322    pub msg_signed: Option<crate::MsgSigStatus>,
1323
1324    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1325    #[cfg_attr(feature = "bon", builder(default))]
1326    pub undocumented: JsonObject,
1327}
1328
1329impl EventData for DeletedMemberUser {
1330    const KIND: EventKind = EventKind::DeletedMemberUser;
1331    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1332        if let Event::DeletedMemberUser(data) = ev {
1333            Ok(data)
1334        } else {
1335            Err(ev)
1336        }
1337    }
1338    fn into_event(self: Arc<Self>) -> Event {
1339        Event::DeletedMemberUser(self)
1340    }
1341}
1342
1343/// ### Group events
1344///
1345/// Bots may use these events to manage users' groups and business address groups.
1346///
1347/// *Please note*: programming groups is more complex than programming direct connections
1348///
1349/// ----
1350///
1351/// Group was deleted by the owner (not bot user).
1352#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1353#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1354#[cfg_attr(feature = "bon", builder(on(String, into)))]
1355pub struct GroupDeleted {
1356    #[serde(rename = "user")]
1357    pub user: crate::User,
1358
1359    #[serde(rename = "groupInfo")]
1360    pub group_info: crate::GroupInfo,
1361
1362    #[serde(rename = "member")]
1363    pub member: crate::GroupMember,
1364
1365    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1366    pub msg_signed: Option<crate::MsgSigStatus>,
1367
1368    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1369    #[cfg_attr(feature = "bon", builder(default))]
1370    pub undocumented: JsonObject,
1371}
1372
1373impl EventData for GroupDeleted {
1374    const KIND: EventKind = EventKind::GroupDeleted;
1375    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1376        if let Event::GroupDeleted(data) = ev {
1377            Ok(data)
1378        } else {
1379            Err(ev)
1380        }
1381    }
1382    fn into_event(self: Arc<Self>) -> Event {
1383        Event::GroupDeleted(self)
1384    }
1385}
1386
1387/// ### Group events
1388///
1389/// Bots may use these events to manage users' groups and business address groups.
1390///
1391/// *Please note*: programming groups is more complex than programming direct connections
1392///
1393/// ----
1394///
1395/// Connected to another group member.
1396#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1397#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1398#[cfg_attr(feature = "bon", builder(on(String, into)))]
1399pub struct ConnectedToGroupMember {
1400    #[serde(rename = "user")]
1401    pub user: crate::User,
1402
1403    #[serde(rename = "groupInfo")]
1404    pub group_info: crate::GroupInfo,
1405
1406    #[serde(rename = "member")]
1407    pub member: crate::GroupMember,
1408
1409    #[serde(rename = "memberContact", skip_serializing_if = "Option::is_none")]
1410    pub member_contact: Option<crate::Contact>,
1411
1412    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1413    #[cfg_attr(feature = "bon", builder(default))]
1414    pub undocumented: JsonObject,
1415}
1416
1417impl EventData for ConnectedToGroupMember {
1418    const KIND: EventKind = EventKind::ConnectedToGroupMember;
1419    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1420        if let Event::ConnectedToGroupMember(data) = ev {
1421            Ok(data)
1422        } else {
1423            Err(ev)
1424        }
1425    }
1426    fn into_event(self: Arc<Self>) -> Event {
1427        Event::ConnectedToGroupMember(self)
1428    }
1429}
1430
1431/// ### Group events
1432///
1433/// Bots may use these events to manage users' groups and business address groups.
1434///
1435/// *Please note*: programming groups is more complex than programming direct connections
1436///
1437/// ----
1438///
1439/// Another group owner, admin or moderator accepted member to the group after review ("knocking").
1440#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1441#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1442#[cfg_attr(feature = "bon", builder(on(String, into)))]
1443pub struct MemberAcceptedByOther {
1444    #[serde(rename = "user")]
1445    pub user: crate::User,
1446
1447    #[serde(rename = "groupInfo")]
1448    pub group_info: crate::GroupInfo,
1449
1450    #[serde(rename = "acceptingMember")]
1451    pub accepting_member: crate::GroupMember,
1452
1453    #[serde(rename = "member")]
1454    pub member: crate::GroupMember,
1455
1456    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1457    #[cfg_attr(feature = "bon", builder(default))]
1458    pub undocumented: JsonObject,
1459}
1460
1461impl EventData for MemberAcceptedByOther {
1462    const KIND: EventKind = EventKind::MemberAcceptedByOther;
1463    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1464        if let Event::MemberAcceptedByOther(data) = ev {
1465            Ok(data)
1466        } else {
1467            Err(ev)
1468        }
1469    }
1470    fn into_event(self: Arc<Self>) -> Event {
1471        Event::MemberAcceptedByOther(self)
1472    }
1473}
1474
1475/// ### Group events
1476///
1477/// Bots may use these events to manage users' groups and business address groups.
1478///
1479/// *Please note*: programming groups is more complex than programming direct connections
1480///
1481/// ----
1482///
1483/// Another member blocked for all members.
1484#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1485#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1486#[cfg_attr(feature = "bon", builder(on(String, into)))]
1487pub struct MemberBlockedForAll {
1488    #[serde(rename = "user")]
1489    pub user: crate::User,
1490
1491    #[serde(rename = "groupInfo")]
1492    pub group_info: crate::GroupInfo,
1493
1494    #[serde(rename = "byMember")]
1495    pub by_member: crate::GroupMember,
1496
1497    #[serde(rename = "member")]
1498    pub member: crate::GroupMember,
1499
1500    #[serde(rename = "blocked", default)]
1501    pub blocked: bool,
1502
1503    #[serde(rename = "msgSigned", skip_serializing_if = "Option::is_none")]
1504    pub msg_signed: Option<crate::MsgSigStatus>,
1505
1506    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1507    #[cfg_attr(feature = "bon", builder(default))]
1508    pub undocumented: JsonObject,
1509}
1510
1511impl EventData for MemberBlockedForAll {
1512    const KIND: EventKind = EventKind::MemberBlockedForAll;
1513    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1514        if let Event::MemberBlockedForAll(data) = ev {
1515            Ok(data)
1516        } else {
1517            Err(ev)
1518        }
1519    }
1520    fn into_event(self: Arc<Self>) -> Event {
1521        Event::MemberBlockedForAll(self)
1522    }
1523}
1524
1525/// ### Group events
1526///
1527/// Bots may use these events to manage users' groups and business address groups.
1528///
1529/// *Please note*: programming groups is more complex than programming direct connections
1530///
1531/// ----
1532///
1533/// Another group member profile updated.
1534#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1535#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1536#[cfg_attr(feature = "bon", builder(on(String, into)))]
1537pub struct GroupMemberUpdated {
1538    #[serde(rename = "user")]
1539    pub user: crate::User,
1540
1541    #[serde(rename = "groupInfo")]
1542    pub group_info: crate::GroupInfo,
1543
1544    #[serde(rename = "fromMember")]
1545    pub from_member: crate::GroupMember,
1546
1547    #[serde(rename = "toMember")]
1548    pub to_member: crate::GroupMember,
1549
1550    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1551    #[cfg_attr(feature = "bon", builder(default))]
1552    pub undocumented: JsonObject,
1553}
1554
1555impl EventData for GroupMemberUpdated {
1556    const KIND: EventKind = EventKind::GroupMemberUpdated;
1557    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1558        if let Event::GroupMemberUpdated(data) = ev {
1559            Ok(data)
1560        } else {
1561            Err(ev)
1562        }
1563    }
1564    fn into_event(self: Arc<Self>) -> Event {
1565        Event::GroupMemberUpdated(self)
1566    }
1567}
1568
1569/// ### Group events
1570///
1571/// Bots may use these events to manage users' groups and business address groups.
1572///
1573/// *Please note*: programming groups is more complex than programming direct connections
1574///
1575/// ----
1576///
1577/// Group link data updated.
1578#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1579#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1580#[cfg_attr(feature = "bon", builder(on(String, into)))]
1581pub struct GroupLinkDataUpdated {
1582    #[serde(rename = "user")]
1583    pub user: crate::User,
1584
1585    #[serde(rename = "groupInfo")]
1586    pub group_info: crate::GroupInfo,
1587
1588    #[serde(rename = "groupLink")]
1589    pub group_link: crate::GroupLink,
1590
1591    #[serde(rename = "groupRelays")]
1592    pub group_relays: Vec<crate::GroupRelay>,
1593
1594    #[serde(rename = "relaysChanged", default)]
1595    pub relays_changed: bool,
1596
1597    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1598    #[cfg_attr(feature = "bon", builder(default))]
1599    pub undocumented: JsonObject,
1600}
1601
1602impl EventData for GroupLinkDataUpdated {
1603    const KIND: EventKind = EventKind::GroupLinkDataUpdated;
1604    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1605        if let Event::GroupLinkDataUpdated(data) = ev {
1606            Ok(data)
1607        } else {
1608            Err(ev)
1609        }
1610    }
1611    fn into_event(self: Arc<Self>) -> Event {
1612        Event::GroupLinkDataUpdated(self)
1613    }
1614}
1615
1616/// ### Group events
1617///
1618/// Bots may use these events to manage users' groups and business address groups.
1619///
1620/// *Please note*: programming groups is more complex than programming direct connections
1621///
1622/// ----
1623///
1624/// Group relay member updated.
1625#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1626#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1627#[cfg_attr(feature = "bon", builder(on(String, into)))]
1628pub struct GroupRelayUpdated {
1629    #[serde(rename = "user")]
1630    pub user: crate::User,
1631
1632    #[serde(rename = "groupInfo")]
1633    pub group_info: crate::GroupInfo,
1634
1635    #[serde(rename = "member")]
1636    pub member: crate::GroupMember,
1637
1638    #[serde(rename = "groupRelay")]
1639    pub group_relay: crate::GroupRelay,
1640
1641    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1642    #[cfg_attr(feature = "bon", builder(default))]
1643    pub undocumented: JsonObject,
1644}
1645
1646impl EventData for GroupRelayUpdated {
1647    const KIND: EventKind = EventKind::GroupRelayUpdated;
1648    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1649        if let Event::GroupRelayUpdated(data) = ev {
1650            Ok(data)
1651        } else {
1652            Err(ev)
1653        }
1654    }
1655    fn into_event(self: Arc<Self>) -> Event {
1656        Event::GroupRelayUpdated(self)
1657    }
1658}
1659
1660/// ### File events
1661///
1662/// Bots that send or receive files may process these events to track delivery status and to process completion.
1663///
1664/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1665///
1666/// Bots that need to send files should use [ApiSendMessages] command.
1667///
1668/// ----
1669///
1670/// File is ready to be received.
1671///
1672/// This event is useful for processing sender file servers and monitoring file reception progress.
1673///
1674/// [ReceiveFile] command can be used before this event.
1675#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1676#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1677#[cfg_attr(feature = "bon", builder(on(String, into)))]
1678pub struct RcvFileDescrReady {
1679    #[serde(rename = "user")]
1680    pub user: crate::User,
1681
1682    #[serde(rename = "chatItem")]
1683    pub chat_item: crate::AChatItem,
1684
1685    #[serde(rename = "rcvFileTransfer")]
1686    pub rcv_file_transfer: crate::RcvFileTransfer,
1687
1688    #[serde(rename = "rcvFileDescr")]
1689    pub rcv_file_descr: crate::RcvFileDescr,
1690
1691    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1692    #[cfg_attr(feature = "bon", builder(default))]
1693    pub undocumented: JsonObject,
1694}
1695
1696impl EventData for RcvFileDescrReady {
1697    const KIND: EventKind = EventKind::RcvFileDescrReady;
1698    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1699        if let Event::RcvFileDescrReady(data) = ev {
1700            Ok(data)
1701        } else {
1702            Err(ev)
1703        }
1704    }
1705    fn into_event(self: Arc<Self>) -> Event {
1706        Event::RcvFileDescrReady(self)
1707    }
1708}
1709
1710/// ### File events
1711///
1712/// Bots that send or receive files may process these events to track delivery status and to process completion.
1713///
1714/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1715///
1716/// Bots that need to send files should use [ApiSendMessages] command.
1717///
1718/// ----
1719///
1720/// File reception is competed.
1721#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1722#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1723#[cfg_attr(feature = "bon", builder(on(String, into)))]
1724pub struct RcvFileComplete {
1725    #[serde(rename = "user")]
1726    pub user: crate::User,
1727
1728    #[serde(rename = "chatItem")]
1729    pub chat_item: crate::AChatItem,
1730
1731    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1732    #[cfg_attr(feature = "bon", builder(default))]
1733    pub undocumented: JsonObject,
1734}
1735
1736impl EventData for RcvFileComplete {
1737    const KIND: EventKind = EventKind::RcvFileComplete;
1738    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1739        if let Event::RcvFileComplete(data) = ev {
1740            Ok(data)
1741        } else {
1742            Err(ev)
1743        }
1744    }
1745    fn into_event(self: Arc<Self>) -> Event {
1746        Event::RcvFileComplete(self)
1747    }
1748}
1749
1750/// ### File events
1751///
1752/// Bots that send or receive files may process these events to track delivery status and to process completion.
1753///
1754/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1755///
1756/// Bots that need to send files should use [ApiSendMessages] command.
1757///
1758/// ----
1759///
1760/// File upload is competed.
1761#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1762#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1763#[cfg_attr(feature = "bon", builder(on(String, into)))]
1764pub struct SndFileCompleteXftp {
1765    #[serde(rename = "user")]
1766    pub user: crate::User,
1767
1768    #[serde(rename = "chatItem")]
1769    pub chat_item: crate::AChatItem,
1770
1771    #[serde(rename = "fileTransferMeta")]
1772    pub file_transfer_meta: crate::FileTransferMeta,
1773
1774    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1775    #[cfg_attr(feature = "bon", builder(default))]
1776    pub undocumented: JsonObject,
1777}
1778
1779impl EventData for SndFileCompleteXftp {
1780    const KIND: EventKind = EventKind::SndFileCompleteXftp;
1781    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1782        if let Event::SndFileCompleteXftp(data) = ev {
1783            Ok(data)
1784        } else {
1785            Err(ev)
1786        }
1787    }
1788    fn into_event(self: Arc<Self>) -> Event {
1789        Event::SndFileCompleteXftp(self)
1790    }
1791}
1792
1793/// ### File events
1794///
1795/// Bots that send or receive files may process these events to track delivery status and to process completion.
1796///
1797/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1798///
1799/// Bots that need to send files should use [ApiSendMessages] command.
1800///
1801/// ----
1802///
1803/// File reception started. This event will be sent after [CEvtRcvFileDescrReady] event.
1804#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1805#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1806#[cfg_attr(feature = "bon", builder(on(String, into)))]
1807pub struct RcvFileStart {
1808    #[serde(rename = "user")]
1809    pub user: crate::User,
1810
1811    #[serde(rename = "chatItem")]
1812    pub chat_item: crate::AChatItem,
1813
1814    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1815    #[cfg_attr(feature = "bon", builder(default))]
1816    pub undocumented: JsonObject,
1817}
1818
1819impl EventData for RcvFileStart {
1820    const KIND: EventKind = EventKind::RcvFileStart;
1821    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1822        if let Event::RcvFileStart(data) = ev {
1823            Ok(data)
1824        } else {
1825            Err(ev)
1826        }
1827    }
1828    fn into_event(self: Arc<Self>) -> Event {
1829        Event::RcvFileStart(self)
1830    }
1831}
1832
1833/// ### File events
1834///
1835/// Bots that send or receive files may process these events to track delivery status and to process completion.
1836///
1837/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1838///
1839/// Bots that need to send files should use [ApiSendMessages] command.
1840///
1841/// ----
1842///
1843/// File was cancelled by the sender. This event may be sent instead of [CEvtRcvFileDescrReady] event.
1844#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1845#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1846#[cfg_attr(feature = "bon", builder(on(String, into)))]
1847pub struct RcvFileSndCancelled {
1848    #[serde(rename = "user")]
1849    pub user: crate::User,
1850
1851    #[serde(rename = "chatItem")]
1852    pub chat_item: crate::AChatItem,
1853
1854    #[serde(rename = "rcvFileTransfer")]
1855    pub rcv_file_transfer: crate::RcvFileTransfer,
1856
1857    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1858    #[cfg_attr(feature = "bon", builder(default))]
1859    pub undocumented: JsonObject,
1860}
1861
1862impl EventData for RcvFileSndCancelled {
1863    const KIND: EventKind = EventKind::RcvFileSndCancelled;
1864    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1865        if let Event::RcvFileSndCancelled(data) = ev {
1866            Ok(data)
1867        } else {
1868            Err(ev)
1869        }
1870    }
1871    fn into_event(self: Arc<Self>) -> Event {
1872        Event::RcvFileSndCancelled(self)
1873    }
1874}
1875
1876/// ### File events
1877///
1878/// Bots that send or receive files may process these events to track delivery status and to process completion.
1879///
1880/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1881///
1882/// Bots that need to send files should use [ApiSendMessages] command.
1883///
1884/// ----
1885///
1886/// This event will be sent when file is automatically accepted because of CLI option.
1887#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1888#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1889#[cfg_attr(feature = "bon", builder(on(String, into)))]
1890pub struct RcvFileAccepted {
1891    #[serde(rename = "user")]
1892    pub user: crate::User,
1893
1894    #[serde(rename = "chatItem")]
1895    pub chat_item: crate::AChatItem,
1896
1897    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1898    #[cfg_attr(feature = "bon", builder(default))]
1899    pub undocumented: JsonObject,
1900}
1901
1902impl EventData for RcvFileAccepted {
1903    const KIND: EventKind = EventKind::RcvFileAccepted;
1904    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1905        if let Event::RcvFileAccepted(data) = ev {
1906            Ok(data)
1907        } else {
1908            Err(ev)
1909        }
1910    }
1911    fn into_event(self: Arc<Self>) -> Event {
1912        Event::RcvFileAccepted(self)
1913    }
1914}
1915
1916/// ### File events
1917///
1918/// Bots that send or receive files may process these events to track delivery status and to process completion.
1919///
1920/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1921///
1922/// Bots that need to send files should use [ApiSendMessages] command.
1923///
1924/// ----
1925///
1926/// Error receiving file.
1927#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1928#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1929#[cfg_attr(feature = "bon", builder(on(String, into)))]
1930pub struct RcvFileError {
1931    #[serde(rename = "user")]
1932    pub user: crate::User,
1933
1934    #[serde(rename = "chatItem_", skip_serializing_if = "Option::is_none")]
1935    pub chat_item: Option<crate::AChatItem>,
1936
1937    #[serde(rename = "agentError")]
1938    pub agent_error: errors::AgentErrorType,
1939
1940    #[serde(rename = "rcvFileTransfer")]
1941    pub rcv_file_transfer: crate::RcvFileTransfer,
1942
1943    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1944    #[cfg_attr(feature = "bon", builder(default))]
1945    pub undocumented: JsonObject,
1946}
1947
1948impl EventData for RcvFileError {
1949    const KIND: EventKind = EventKind::RcvFileError;
1950    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1951        if let Event::RcvFileError(data) = ev {
1952            Ok(data)
1953        } else {
1954            Err(ev)
1955        }
1956    }
1957    fn into_event(self: Arc<Self>) -> Event {
1958        Event::RcvFileError(self)
1959    }
1960}
1961
1962/// ### File events
1963///
1964/// Bots that send or receive files may process these events to track delivery status and to process completion.
1965///
1966/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
1967///
1968/// Bots that need to send files should use [ApiSendMessages] command.
1969///
1970/// ----
1971///
1972/// Warning when receiving file. It can happen when CLI settings do not allow to connect to file server(s).
1973#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1974#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1975#[cfg_attr(feature = "bon", builder(on(String, into)))]
1976pub struct RcvFileWarning {
1977    #[serde(rename = "user")]
1978    pub user: crate::User,
1979
1980    #[serde(rename = "chatItem_", skip_serializing_if = "Option::is_none")]
1981    pub chat_item: Option<crate::AChatItem>,
1982
1983    #[serde(rename = "agentError")]
1984    pub agent_error: errors::AgentErrorType,
1985
1986    #[serde(rename = "rcvFileTransfer")]
1987    pub rcv_file_transfer: crate::RcvFileTransfer,
1988
1989    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
1990    #[cfg_attr(feature = "bon", builder(default))]
1991    pub undocumented: JsonObject,
1992}
1993
1994impl EventData for RcvFileWarning {
1995    const KIND: EventKind = EventKind::RcvFileWarning;
1996    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
1997        if let Event::RcvFileWarning(data) = ev {
1998            Ok(data)
1999        } else {
2000            Err(ev)
2001        }
2002    }
2003    fn into_event(self: Arc<Self>) -> Event {
2004        Event::RcvFileWarning(self)
2005    }
2006}
2007
2008/// ### File events
2009///
2010/// Bots that send or receive files may process these events to track delivery status and to process completion.
2011///
2012/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
2013///
2014/// Bots that need to send files should use [ApiSendMessages] command.
2015///
2016/// ----
2017///
2018/// Error sending file.
2019#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2020#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2021#[cfg_attr(feature = "bon", builder(on(String, into)))]
2022pub struct SndFileError {
2023    #[serde(rename = "user")]
2024    pub user: crate::User,
2025
2026    #[serde(rename = "chatItem_", skip_serializing_if = "Option::is_none")]
2027    pub chat_item: Option<crate::AChatItem>,
2028
2029    #[serde(rename = "fileTransferMeta")]
2030    pub file_transfer_meta: crate::FileTransferMeta,
2031
2032    #[serde(rename = "errorMessage")]
2033    pub error_message: String,
2034
2035    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2036    #[cfg_attr(feature = "bon", builder(default))]
2037    pub undocumented: JsonObject,
2038}
2039
2040impl EventData for SndFileError {
2041    const KIND: EventKind = EventKind::SndFileError;
2042    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2043        if let Event::SndFileError(data) = ev {
2044            Ok(data)
2045        } else {
2046            Err(ev)
2047        }
2048    }
2049    fn into_event(self: Arc<Self>) -> Event {
2050        Event::SndFileError(self)
2051    }
2052}
2053
2054/// ### File events
2055///
2056/// Bots that send or receive files may process these events to track delivery status and to process completion.
2057///
2058/// Bots that need to receive or moderate files (e.g., based on name, size or extension), can use relevant commands (e.g., [ReceiveFile] or [ApiDeleteMemberChatItem]) when processing [NewChatItems] event.
2059///
2060/// Bots that need to send files should use [ApiSendMessages] command.
2061///
2062/// ----
2063///
2064/// Warning when sending file.
2065#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2066#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2067#[cfg_attr(feature = "bon", builder(on(String, into)))]
2068pub struct SndFileWarning {
2069    #[serde(rename = "user")]
2070    pub user: crate::User,
2071
2072    #[serde(rename = "chatItem_", skip_serializing_if = "Option::is_none")]
2073    pub chat_item: Option<crate::AChatItem>,
2074
2075    #[serde(rename = "fileTransferMeta")]
2076    pub file_transfer_meta: crate::FileTransferMeta,
2077
2078    #[serde(rename = "errorMessage")]
2079    pub error_message: String,
2080
2081    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2082    #[cfg_attr(feature = "bon", builder(default))]
2083    pub undocumented: JsonObject,
2084}
2085
2086impl EventData for SndFileWarning {
2087    const KIND: EventKind = EventKind::SndFileWarning;
2088    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2089        if let Event::SndFileWarning(data) = ev {
2090            Ok(data)
2091        } else {
2092            Err(ev)
2093        }
2094    }
2095    fn into_event(self: Arc<Self>) -> Event {
2096        Event::SndFileWarning(self)
2097    }
2098}
2099
2100/// ### Connection progress events
2101///
2102/// Bots may use these events to track progress of connections for monitoring or debugging.
2103///
2104/// ----
2105///
2106/// Automatically accepting contact request via bot's SimpleX address with auto-accept enabled.
2107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2108#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2109#[cfg_attr(feature = "bon", builder(on(String, into)))]
2110pub struct AcceptingContactRequest {
2111    #[serde(rename = "user")]
2112    pub user: crate::User,
2113
2114    #[serde(rename = "contact")]
2115    pub contact: crate::Contact,
2116
2117    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2118    #[cfg_attr(feature = "bon", builder(default))]
2119    pub undocumented: JsonObject,
2120}
2121
2122impl EventData for AcceptingContactRequest {
2123    const KIND: EventKind = EventKind::AcceptingContactRequest;
2124    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2125        if let Event::AcceptingContactRequest(data) = ev {
2126            Ok(data)
2127        } else {
2128            Err(ev)
2129        }
2130    }
2131    fn into_event(self: Arc<Self>) -> Event {
2132        Event::AcceptingContactRequest(self)
2133    }
2134}
2135
2136/// ### Connection progress events
2137///
2138/// Bots may use these events to track progress of connections for monitoring or debugging.
2139///
2140/// ----
2141///
2142/// Automatically accepting contact request via bot's business address.
2143#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2144#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2145#[cfg_attr(feature = "bon", builder(on(String, into)))]
2146pub struct AcceptingBusinessRequest {
2147    #[serde(rename = "user")]
2148    pub user: crate::User,
2149
2150    #[serde(rename = "groupInfo")]
2151    pub group_info: crate::GroupInfo,
2152
2153    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2154    #[cfg_attr(feature = "bon", builder(default))]
2155    pub undocumented: JsonObject,
2156}
2157
2158impl EventData for AcceptingBusinessRequest {
2159    const KIND: EventKind = EventKind::AcceptingBusinessRequest;
2160    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2161        if let Event::AcceptingBusinessRequest(data) = ev {
2162            Ok(data)
2163        } else {
2164            Err(ev)
2165        }
2166    }
2167    fn into_event(self: Arc<Self>) -> Event {
2168        Event::AcceptingBusinessRequest(self)
2169    }
2170}
2171
2172/// ### Connection progress events
2173///
2174/// Bots may use these events to track progress of connections for monitoring or debugging.
2175///
2176/// ----
2177///
2178/// Contact confirmed connection.
2179///
2180/// Sent when contact started connecting via bot's 1-time invitation link or when bot connects to another SimpleX address.
2181#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2182#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2183#[cfg_attr(feature = "bon", builder(on(String, into)))]
2184pub struct ContactConnecting {
2185    #[serde(rename = "user")]
2186    pub user: crate::User,
2187
2188    #[serde(rename = "contact")]
2189    pub contact: crate::Contact,
2190
2191    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2192    #[cfg_attr(feature = "bon", builder(default))]
2193    pub undocumented: JsonObject,
2194}
2195
2196impl EventData for ContactConnecting {
2197    const KIND: EventKind = EventKind::ContactConnecting;
2198    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2199        if let Event::ContactConnecting(data) = ev {
2200            Ok(data)
2201        } else {
2202            Err(ev)
2203        }
2204    }
2205    fn into_event(self: Arc<Self>) -> Event {
2206        Event::ContactConnecting(self)
2207    }
2208}
2209
2210/// ### Connection progress events
2211///
2212/// Bots may use these events to track progress of connections for monitoring or debugging.
2213///
2214/// ----
2215///
2216/// Contact confirmed connection.
2217///
2218/// Sent when bot connects to another business address.
2219#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2220#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2221#[cfg_attr(feature = "bon", builder(on(String, into)))]
2222pub struct BusinessLinkConnecting {
2223    #[serde(rename = "user")]
2224    pub user: crate::User,
2225
2226    #[serde(rename = "groupInfo")]
2227    pub group_info: crate::GroupInfo,
2228
2229    #[serde(rename = "hostMember")]
2230    pub host_member: crate::GroupMember,
2231
2232    #[serde(rename = "fromContact")]
2233    pub from_contact: crate::Contact,
2234
2235    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2236    #[cfg_attr(feature = "bon", builder(default))]
2237    pub undocumented: JsonObject,
2238}
2239
2240impl EventData for BusinessLinkConnecting {
2241    const KIND: EventKind = EventKind::BusinessLinkConnecting;
2242    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2243        if let Event::BusinessLinkConnecting(data) = ev {
2244            Ok(data)
2245        } else {
2246            Err(ev)
2247        }
2248    }
2249    fn into_event(self: Arc<Self>) -> Event {
2250        Event::BusinessLinkConnecting(self)
2251    }
2252}
2253
2254/// ### Connection progress events
2255///
2256/// Bots may use these events to track progress of connections for monitoring or debugging.
2257///
2258/// ----
2259///
2260/// Group member is announced to the group and will be connecting to bot.
2261#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2262#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2263#[cfg_attr(feature = "bon", builder(on(String, into)))]
2264pub struct JoinedGroupMemberConnecting {
2265    #[serde(rename = "user")]
2266    pub user: crate::User,
2267
2268    #[serde(rename = "groupInfo")]
2269    pub group_info: crate::GroupInfo,
2270
2271    #[serde(rename = "hostMember")]
2272    pub host_member: crate::GroupMember,
2273
2274    #[serde(rename = "member")]
2275    pub member: crate::GroupMember,
2276
2277    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2278    #[cfg_attr(feature = "bon", builder(default))]
2279    pub undocumented: JsonObject,
2280}
2281
2282impl EventData for JoinedGroupMemberConnecting {
2283    const KIND: EventKind = EventKind::JoinedGroupMemberConnecting;
2284    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2285        if let Event::JoinedGroupMemberConnecting(data) = ev {
2286            Ok(data)
2287        } else {
2288            Err(ev)
2289        }
2290    }
2291    fn into_event(self: Arc<Self>) -> Event {
2292        Event::JoinedGroupMemberConnecting(self)
2293    }
2294}
2295
2296/// ### Connection progress events
2297///
2298/// Bots may use these events to track progress of connections for monitoring or debugging.
2299///
2300/// ----
2301///
2302/// Sent when another user joins group via bot's link.
2303#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2304#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2305#[cfg_attr(feature = "bon", builder(on(String, into)))]
2306pub struct SentGroupInvitation {
2307    #[serde(rename = "user")]
2308    pub user: crate::User,
2309
2310    #[serde(rename = "groupInfo")]
2311    pub group_info: crate::GroupInfo,
2312
2313    #[serde(rename = "contact")]
2314    pub contact: crate::Contact,
2315
2316    #[serde(rename = "member")]
2317    pub member: crate::GroupMember,
2318
2319    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2320    #[cfg_attr(feature = "bon", builder(default))]
2321    pub undocumented: JsonObject,
2322}
2323
2324impl EventData for SentGroupInvitation {
2325    const KIND: EventKind = EventKind::SentGroupInvitation;
2326    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2327        if let Event::SentGroupInvitation(data) = ev {
2328            Ok(data)
2329        } else {
2330            Err(ev)
2331        }
2332    }
2333    fn into_event(self: Arc<Self>) -> Event {
2334        Event::SentGroupInvitation(self)
2335    }
2336}
2337
2338/// ### Connection progress events
2339///
2340/// Bots may use these events to track progress of connections for monitoring or debugging.
2341///
2342/// ----
2343///
2344/// Sent when bot joins group via another user link.
2345#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2346#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2347#[cfg_attr(feature = "bon", builder(on(String, into)))]
2348pub struct GroupLinkConnecting {
2349    #[serde(rename = "user")]
2350    pub user: crate::User,
2351
2352    #[serde(rename = "groupInfo")]
2353    pub group_info: crate::GroupInfo,
2354
2355    #[serde(rename = "hostMember")]
2356    pub host_member: crate::GroupMember,
2357
2358    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2359    #[cfg_attr(feature = "bon", builder(default))]
2360    pub undocumented: JsonObject,
2361}
2362
2363impl EventData for GroupLinkConnecting {
2364    const KIND: EventKind = EventKind::GroupLinkConnecting;
2365    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2366        if let Event::GroupLinkConnecting(data) = ev {
2367            Ok(data)
2368        } else {
2369            Err(ev)
2370        }
2371    }
2372    fn into_event(self: Arc<Self>) -> Event {
2373        Event::GroupLinkConnecting(self)
2374    }
2375}
2376
2377/// ### Network connection events
2378///
2379///
2380/// ----
2381///
2382/// Messaging or file server connected
2383#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2384#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2385#[cfg_attr(feature = "bon", builder(on(String, into)))]
2386pub struct HostConnected {
2387    #[serde(rename = "protocol")]
2388    pub protocol: String,
2389
2390    #[serde(rename = "transportHost")]
2391    pub transport_host: String,
2392
2393    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2394    #[cfg_attr(feature = "bon", builder(default))]
2395    pub undocumented: JsonObject,
2396}
2397
2398impl EventData for HostConnected {
2399    const KIND: EventKind = EventKind::HostConnected;
2400    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2401        if let Event::HostConnected(data) = ev {
2402            Ok(data)
2403        } else {
2404            Err(ev)
2405        }
2406    }
2407    fn into_event(self: Arc<Self>) -> Event {
2408        Event::HostConnected(self)
2409    }
2410}
2411
2412/// ### Network connection events
2413///
2414///
2415/// ----
2416///
2417/// Messaging or file server disconnected
2418#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2419#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2420#[cfg_attr(feature = "bon", builder(on(String, into)))]
2421pub struct HostDisconnected {
2422    #[serde(rename = "protocol")]
2423    pub protocol: String,
2424
2425    #[serde(rename = "transportHost")]
2426    pub transport_host: String,
2427
2428    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2429    #[cfg_attr(feature = "bon", builder(default))]
2430    pub undocumented: JsonObject,
2431}
2432
2433impl EventData for HostDisconnected {
2434    const KIND: EventKind = EventKind::HostDisconnected;
2435    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2436        if let Event::HostDisconnected(data) = ev {
2437            Ok(data)
2438        } else {
2439            Err(ev)
2440        }
2441    }
2442    fn into_event(self: Arc<Self>) -> Event {
2443        Event::HostDisconnected(self)
2444    }
2445}
2446
2447/// ### Network connection events
2448///
2449///
2450/// ----
2451///
2452/// Messaging subscription status changed
2453#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2454#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2455#[cfg_attr(feature = "bon", builder(on(String, into)))]
2456pub struct SubscriptionStatus {
2457    #[serde(rename = "server")]
2458    pub server: String,
2459
2460    #[serde(rename = "subscriptionStatus")]
2461    pub subscription_status: crate::SubscriptionStatus,
2462
2463    #[serde(rename = "connections")]
2464    pub connections: Vec<String>,
2465
2466    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2467    #[cfg_attr(feature = "bon", builder(default))]
2468    pub undocumented: JsonObject,
2469}
2470
2471impl EventData for SubscriptionStatus {
2472    const KIND: EventKind = EventKind::SubscriptionStatus;
2473    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2474        if let Event::SubscriptionStatus(data) = ev {
2475            Ok(data)
2476        } else {
2477            Err(ev)
2478        }
2479    }
2480    fn into_event(self: Arc<Self>) -> Event {
2481        Event::SubscriptionStatus(self)
2482    }
2483}
2484
2485/// ### Error events
2486///
2487/// Bots may log these events for debugging. There will be many error events - this does NOT indicate a malfunction - e.g., they may happen because of bad network connectivity, or because messages may be delivered to deleted chats for a short period of time (they will be ignored).
2488///
2489/// ----
2490///
2491/// Message error.
2492#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2493#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2494#[cfg_attr(feature = "bon", builder(on(String, into)))]
2495pub struct MessageError {
2496    #[serde(rename = "user")]
2497    pub user: crate::User,
2498
2499    #[serde(rename = "severity")]
2500    pub severity: String,
2501
2502    #[serde(rename = "errorMessage")]
2503    pub error_message: String,
2504
2505    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2506    #[cfg_attr(feature = "bon", builder(default))]
2507    pub undocumented: JsonObject,
2508}
2509
2510impl EventData for MessageError {
2511    const KIND: EventKind = EventKind::MessageError;
2512    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2513        if let Event::MessageError(data) = ev {
2514            Ok(data)
2515        } else {
2516            Err(ev)
2517        }
2518    }
2519    fn into_event(self: Arc<Self>) -> Event {
2520        Event::MessageError(self)
2521    }
2522}
2523
2524/// ### Error events
2525///
2526/// Bots may log these events for debugging. There will be many error events - this does NOT indicate a malfunction - e.g., they may happen because of bad network connectivity, or because messages may be delivered to deleted chats for a short period of time (they will be ignored).
2527///
2528/// ----
2529///
2530/// Chat error (only used in WebSockets API).
2531#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2532#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2533#[cfg_attr(feature = "bon", builder(on(String, into)))]
2534pub struct ChatError {
2535    #[serde(rename = "chatError")]
2536    pub chat_error: errors::ChatError,
2537
2538    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2539    #[cfg_attr(feature = "bon", builder(default))]
2540    pub undocumented: JsonObject,
2541}
2542
2543impl EventData for ChatError {
2544    const KIND: EventKind = EventKind::ChatError;
2545    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2546        if let Event::ChatError(data) = ev {
2547            Ok(data)
2548        } else {
2549            Err(ev)
2550        }
2551    }
2552    fn into_event(self: Arc<Self>) -> Event {
2553        Event::ChatError(self)
2554    }
2555}
2556
2557/// ### Error events
2558///
2559/// Bots may log these events for debugging. There will be many error events - this does NOT indicate a malfunction - e.g., they may happen because of bad network connectivity, or because messages may be delivered to deleted chats for a short period of time (they will be ignored).
2560///
2561/// ----
2562///
2563/// Chat errors.
2564#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2565#[cfg_attr(feature = "bon", derive(::bon::Builder))]
2566#[cfg_attr(feature = "bon", builder(on(String, into)))]
2567pub struct ChatErrors {
2568    #[serde(rename = "chatErrors")]
2569    pub chat_errors: Vec<errors::ChatError>,
2570
2571    #[serde(flatten, skip_serializing_if = "JsonObject::is_null")]
2572    #[cfg_attr(feature = "bon", builder(default))]
2573    pub undocumented: JsonObject,
2574}
2575
2576impl EventData for ChatErrors {
2577    const KIND: EventKind = EventKind::ChatErrors;
2578    fn from_event(ev: Event) -> Result<Arc<Self>, Event> {
2579        if let Event::ChatErrors(data) = ev {
2580            Ok(data)
2581        } else {
2582            Err(ev)
2583        }
2584    }
2585    fn into_event(self: Arc<Self>) -> Event {
2586        Event::ChatErrors(self)
2587    }
2588}