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