titanium_model/builder/
thread.rs

1use crate::TitanString;
2
3/// Payload for starting a thread.
4#[derive(Debug, Clone, serde::Serialize, Default)]
5pub struct StartThread<'a> {
6    pub name: TitanString<'a>,
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub auto_archive_duration: Option<u32>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub type_: Option<u8>, // For Start Thread without Message
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub invitable: Option<bool>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub rate_limit_per_user: Option<u32>,
15}
16
17/// Builder for starting a Thread.
18#[derive(Debug, Clone)]
19#[must_use]
20pub struct StartThreadBuilder<'a> {
21    params: StartThread<'a>,
22}
23
24impl<'a> StartThreadBuilder<'a> {
25    /// Create a new `StartThreadBuilder`.
26    pub fn new(name: impl Into<TitanString<'a>>) -> Self {
27        Self {
28            params: StartThread {
29                name: name.into(),
30                ..Default::default()
31            },
32        }
33    }
34
35    /// Set auto archive duration (60, 1440, 4320, 10080).
36    pub fn auto_archive_duration(mut self, duration: u32) -> Self {
37        self.params.auto_archive_duration = Some(duration);
38        self
39    }
40
41    /// Set thread type (for standalone threads).
42    pub fn kind(mut self, kind: u8) -> Self {
43        self.params.type_ = Some(kind);
44        self
45    }
46
47    /// Set invitable (private threads).
48    pub fn invitable(mut self, invitable: bool) -> Self {
49        self.params.invitable = Some(invitable);
50        self
51    }
52
53    /// Set rate limit per user.
54    pub fn rate_limit_per_user(mut self, limit: u32) -> Self {
55        self.params.rate_limit_per_user = Some(limit);
56        self
57    }
58
59    /// Build the `StartThread` payload.
60    #[must_use]
61    pub fn build(self) -> StartThread<'a> {
62        self.params
63    }
64}