Skip to main content

imessage_serializers/
config.rs

1//! Serializer configuration types.
2
3/// Configuration for message serialization.
4#[derive(Debug, Clone)]
5pub struct MessageSerializerConfig {
6    pub parse_attributed_body: bool,
7    pub parse_message_summary: bool,
8    pub parse_payload_data: bool,
9    pub include_chats: bool,
10    pub load_chat_participants: bool,
11}
12
13impl Default for MessageSerializerConfig {
14    fn default() -> Self {
15        Self {
16            parse_attributed_body: false,
17            parse_message_summary: false,
18            parse_payload_data: false,
19            include_chats: true,
20            load_chat_participants: true,
21        }
22    }
23}
24
25impl MessageSerializerConfig {
26    /// Config for serializing sent messages (after send/react/edit/unsend).
27    /// Defaults: parseAttributedBody: true, parseMessageSummary: true,
28    /// parsePayloadData: true, loadChatParticipants: false for sent message responses.
29    pub fn for_sent_message() -> Self {
30        Self {
31            parse_attributed_body: true,
32            parse_message_summary: true,
33            parse_payload_data: true,
34            include_chats: true,
35            load_chat_participants: false,
36        }
37    }
38}
39
40/// Configuration for attachment serialization.
41#[derive(Debug, Clone)]
42pub struct AttachmentSerializerConfig {
43    pub load_data: bool,
44    pub load_metadata: bool,
45}
46
47impl Default for AttachmentSerializerConfig {
48    fn default() -> Self {
49        Self {
50            load_data: false,
51            load_metadata: true,
52        }
53    }
54}
55
56/// Configuration for chat serialization.
57#[derive(Debug, Clone)]
58pub struct ChatSerializerConfig {
59    pub include_participants: bool,
60    pub include_messages: bool,
61}
62
63impl Default for ChatSerializerConfig {
64    fn default() -> Self {
65        Self {
66            include_participants: true,
67            include_messages: false,
68        }
69    }
70}