jacquard_api/com_atproto/
label.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.label.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod query_labels;
9
10#[cfg(feature = "streaming")]
11pub mod subscribe_labels;
12
13/// Metadata tag on an atproto resource (eg, repo or record).
14#[jacquard_derive::lexicon]
15#[derive(
16    serde::Serialize,
17    serde::Deserialize,
18    Debug,
19    Clone,
20    PartialEq,
21    Eq,
22    jacquard_derive::IntoStatic,
23    bon::Builder
24)]
25#[serde(rename_all = "camelCase")]
26pub struct Label<'a> {
27    /// Optionally, CID specifying the specific version of 'uri' resource this label applies to.
28    #[serde(skip_serializing_if = "std::option::Option::is_none")]
29    #[builder(into)]
30    #[serde(borrow)]
31    pub cid: Option<jacquard_common::types::string::Cid<'a>>,
32    /// Timestamp when this label was created.
33    pub cts: jacquard_common::types::string::Datetime,
34    /// Timestamp at which this label expires (no longer applies).
35    #[serde(skip_serializing_if = "std::option::Option::is_none")]
36    #[builder(into)]
37    pub exp: Option<jacquard_common::types::string::Datetime>,
38    /// If true, this is a negation label, overwriting a previous label.
39    #[serde(skip_serializing_if = "std::option::Option::is_none")]
40    #[builder(into)]
41    pub neg: Option<bool>,
42    /// Signature of dag-cbor encoded label.
43    #[serde(skip_serializing_if = "std::option::Option::is_none")]
44    #[builder(into)]
45    pub sig: Option<bytes::Bytes>,
46    /// DID of the actor who created this label.
47    #[serde(borrow)]
48    pub src: jacquard_common::types::string::Did<'a>,
49    /// AT URI of the record, repository (account), or other resource that this label applies to.
50    #[serde(borrow)]
51    pub uri: jacquard_common::types::string::Uri<'a>,
52    /// The short string name of the value or type of this label.
53    #[serde(borrow)]
54    #[builder(into)]
55    pub val: jacquard_common::CowStr<'a>,
56    /// The AT Protocol version of the label object.
57    #[serde(skip_serializing_if = "std::option::Option::is_none")]
58    #[builder(into)]
59    pub ver: Option<i64>,
60}
61
62#[derive(Debug, Clone, PartialEq, Eq, Hash)]
63pub enum LabelValue<'a> {
64    Hide,
65    NoPromote,
66    Warn,
67    NoUnauthenticated,
68    DmcaViolation,
69    Doxxing,
70    Porn,
71    Sexual,
72    Nudity,
73    Nsfl,
74    Gore,
75    Other(jacquard_common::CowStr<'a>),
76}
77
78impl<'a> LabelValue<'a> {
79    pub fn as_str(&self) -> &str {
80        match self {
81            Self::Hide => "!hide",
82            Self::NoPromote => "!no-promote",
83            Self::Warn => "!warn",
84            Self::NoUnauthenticated => "!no-unauthenticated",
85            Self::DmcaViolation => "dmca-violation",
86            Self::Doxxing => "doxxing",
87            Self::Porn => "porn",
88            Self::Sexual => "sexual",
89            Self::Nudity => "nudity",
90            Self::Nsfl => "nsfl",
91            Self::Gore => "gore",
92            Self::Other(s) => s.as_ref(),
93        }
94    }
95}
96
97impl<'a> From<&'a str> for LabelValue<'a> {
98    fn from(s: &'a str) -> Self {
99        match s {
100            "!hide" => Self::Hide,
101            "!no-promote" => Self::NoPromote,
102            "!warn" => Self::Warn,
103            "!no-unauthenticated" => Self::NoUnauthenticated,
104            "dmca-violation" => Self::DmcaViolation,
105            "doxxing" => Self::Doxxing,
106            "porn" => Self::Porn,
107            "sexual" => Self::Sexual,
108            "nudity" => Self::Nudity,
109            "nsfl" => Self::Nsfl,
110            "gore" => Self::Gore,
111            _ => Self::Other(jacquard_common::CowStr::from(s)),
112        }
113    }
114}
115
116impl<'a> From<String> for LabelValue<'a> {
117    fn from(s: String) -> Self {
118        match s.as_str() {
119            "!hide" => Self::Hide,
120            "!no-promote" => Self::NoPromote,
121            "!warn" => Self::Warn,
122            "!no-unauthenticated" => Self::NoUnauthenticated,
123            "dmca-violation" => Self::DmcaViolation,
124            "doxxing" => Self::Doxxing,
125            "porn" => Self::Porn,
126            "sexual" => Self::Sexual,
127            "nudity" => Self::Nudity,
128            "nsfl" => Self::Nsfl,
129            "gore" => Self::Gore,
130            _ => Self::Other(jacquard_common::CowStr::from(s)),
131        }
132    }
133}
134
135impl<'a> AsRef<str> for LabelValue<'a> {
136    fn as_ref(&self) -> &str {
137        self.as_str()
138    }
139}
140
141impl<'a> serde::Serialize for LabelValue<'a> {
142    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
143    where
144        S: serde::Serializer,
145    {
146        serializer.serialize_str(self.as_str())
147    }
148}
149
150impl<'de, 'a> serde::Deserialize<'de> for LabelValue<'a>
151where
152    'de: 'a,
153{
154    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
155    where
156        D: serde::Deserializer<'de>,
157    {
158        let s = <&'de str>::deserialize(deserializer)?;
159        Ok(Self::from(s))
160    }
161}
162
163impl jacquard_common::IntoStatic for LabelValue<'_> {
164    type Output = LabelValue<'static>;
165    fn into_static(self) -> Self::Output {
166        match self {
167            LabelValue::Hide => LabelValue::Hide,
168            LabelValue::NoPromote => LabelValue::NoPromote,
169            LabelValue::Warn => LabelValue::Warn,
170            LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
171            LabelValue::DmcaViolation => LabelValue::DmcaViolation,
172            LabelValue::Doxxing => LabelValue::Doxxing,
173            LabelValue::Porn => LabelValue::Porn,
174            LabelValue::Sexual => LabelValue::Sexual,
175            LabelValue::Nudity => LabelValue::Nudity,
176            LabelValue::Nsfl => LabelValue::Nsfl,
177            LabelValue::Gore => LabelValue::Gore,
178            LabelValue::Other(v) => LabelValue::Other(v.into_static()),
179        }
180    }
181}
182
183/// Declares a label value and its expected interpretations and behaviors.
184#[jacquard_derive::lexicon]
185#[derive(
186    serde::Serialize,
187    serde::Deserialize,
188    Debug,
189    Clone,
190    PartialEq,
191    Eq,
192    jacquard_derive::IntoStatic,
193    bon::Builder
194)]
195#[serde(rename_all = "camelCase")]
196pub struct LabelValueDefinition<'a> {
197    /// Does the user need to have adult content enabled in order to configure this label?
198    #[serde(skip_serializing_if = "std::option::Option::is_none")]
199    #[builder(into)]
200    pub adult_only: Option<bool>,
201    /// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
202    #[serde(borrow)]
203    #[builder(into)]
204    pub blurs: jacquard_common::CowStr<'a>,
205    /// The default setting for this label.
206    #[serde(skip_serializing_if = "std::option::Option::is_none")]
207    #[builder(into)]
208    #[serde(borrow)]
209    pub default_setting: Option<jacquard_common::CowStr<'a>>,
210    /// The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
211    #[serde(borrow)]
212    #[builder(into)]
213    pub identifier: jacquard_common::CowStr<'a>,
214    #[serde(borrow)]
215    pub locales: Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>,
216    /// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
217    #[serde(borrow)]
218    #[builder(into)]
219    pub severity: jacquard_common::CowStr<'a>,
220}
221
222/// Strings which describe the label in the UI, localized into a specific language.
223#[jacquard_derive::lexicon]
224#[derive(
225    serde::Serialize,
226    serde::Deserialize,
227    Debug,
228    Clone,
229    PartialEq,
230    Eq,
231    jacquard_derive::IntoStatic,
232    bon::Builder
233)]
234#[serde(rename_all = "camelCase")]
235pub struct LabelValueDefinitionStrings<'a> {
236    /// A longer description of what the label means and why it might be applied.
237    #[serde(borrow)]
238    #[builder(into)]
239    pub description: jacquard_common::CowStr<'a>,
240    /// The code of the language these strings are written in.
241    pub lang: jacquard_common::types::string::Language,
242    /// A short human-readable name for the label.
243    #[serde(borrow)]
244    #[builder(into)]
245    pub name: jacquard_common::CowStr<'a>,
246}
247
248/// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.
249#[jacquard_derive::lexicon]
250#[derive(
251    serde::Serialize,
252    serde::Deserialize,
253    Debug,
254    Clone,
255    PartialEq,
256    Eq,
257    jacquard_derive::IntoStatic,
258    Default
259)]
260#[serde(rename_all = "camelCase")]
261pub struct SelfLabel<'a> {
262    /// The short string name of the value or type of this label.
263    #[serde(borrow)]
264    pub val: jacquard_common::CowStr<'a>,
265}
266
267/// Metadata tags on an atproto record, published by the author within the record.
268#[jacquard_derive::lexicon]
269#[derive(
270    serde::Serialize,
271    serde::Deserialize,
272    Debug,
273    Clone,
274    PartialEq,
275    Eq,
276    jacquard_derive::IntoStatic,
277    bon::Builder
278)]
279#[serde(rename_all = "camelCase")]
280pub struct SelfLabels<'a> {
281    #[serde(borrow)]
282    pub values: Vec<crate::com_atproto::label::SelfLabel<'a>>,
283}