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