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