pub mod query_labels;
#[cfg(feature = "streaming")]
pub mod subscribe_labels;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
use jacquard_common::deps::bytes::Bytes;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, Cid, Datetime, Language, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::label;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Label<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub cts: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub exp: Option<Datetime>,
#[serde(skip_serializing_if = "Option::is_none")]
pub neg: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
pub sig: Option<Bytes>,
pub src: Did<S>,
pub uri: UriValue<S>,
pub val: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub ver: Option<i64>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValue<S: BosStr = DefaultStr> {
Hide,
Warn,
NoUnauthenticated,
Porn,
Sexual,
Nudity,
GraphicMedia,
Bot,
Other(S),
}
impl<S: BosStr> LabelValue<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Hide => "!hide",
Self::Warn => "!warn",
Self::NoUnauthenticated => "!no-unauthenticated",
Self::Porn => "porn",
Self::Sexual => "sexual",
Self::Nudity => "nudity",
Self::GraphicMedia => "graphic-media",
Self::Bot => "bot",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"!hide" => Self::Hide,
"!warn" => Self::Warn,
"!no-unauthenticated" => Self::NoUnauthenticated,
"porn" => Self::Porn,
"sexual" => Self::Sexual,
"nudity" => Self::Nudity,
"graphic-media" => Self::GraphicMedia,
"bot" => Self::Bot,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> AsRef<str> for LabelValue<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> core::fmt::Display for LabelValue<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> Serialize for LabelValue<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for LabelValue<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr> jacquard_common::IntoStatic for LabelValue<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = LabelValue<S::Output>;
fn into_static(self) -> Self::Output {
match self {
LabelValue::Hide => LabelValue::Hide,
LabelValue::Warn => LabelValue::Warn,
LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
LabelValue::Porn => LabelValue::Porn,
LabelValue::Sexual => LabelValue::Sexual,
LabelValue::Nudity => LabelValue::Nudity,
LabelValue::GraphicMedia => LabelValue::GraphicMedia,
LabelValue::Bot => LabelValue::Bot,
LabelValue::Other(v) => LabelValue::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelValueDefinition<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub adult_only: Option<bool>,
pub blurs: LabelValueDefinitionBlurs<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub default_setting: Option<LabelValueDefinitionDefaultSetting<S>>,
pub identifier: S,
pub locales: Vec<label::LabelValueDefinitionStrings<S>>,
pub severity: LabelValueDefinitionSeverity<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionBlurs<S: BosStr = DefaultStr> {
Content,
Media,
None,
Other(S),
}
impl<S: BosStr> LabelValueDefinitionBlurs<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Content => "content",
Self::Media => "media",
Self::None => "none",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"content" => Self::Content,
"media" => Self::Media,
"none" => Self::None,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for LabelValueDefinitionBlurs<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for LabelValueDefinitionBlurs<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for LabelValueDefinitionBlurs<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionBlurs<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for LabelValueDefinitionBlurs<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionBlurs<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = LabelValueDefinitionBlurs<S::Output>;
fn into_static(self) -> Self::Output {
match self {
LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content,
LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media,
LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None,
LabelValueDefinitionBlurs::Other(v) => {
LabelValueDefinitionBlurs::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionDefaultSetting<S: BosStr = DefaultStr> {
Ignore,
Warn,
Hide,
Other(S),
}
impl<S: BosStr> LabelValueDefinitionDefaultSetting<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Ignore => "ignore",
Self::Warn => "warn",
Self::Hide => "hide",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"ignore" => Self::Ignore,
"warn" => Self::Warn,
"hide" => Self::Hide,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for LabelValueDefinitionDefaultSetting<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for LabelValueDefinitionDefaultSetting<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for LabelValueDefinitionDefaultSetting<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionDefaultSetting<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for LabelValueDefinitionDefaultSetting<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = LabelValueDefinitionDefaultSetting<S::Output>;
fn into_static(self) -> Self::Output {
match self {
LabelValueDefinitionDefaultSetting::Ignore => {
LabelValueDefinitionDefaultSetting::Ignore
}
LabelValueDefinitionDefaultSetting::Warn => {
LabelValueDefinitionDefaultSetting::Warn
}
LabelValueDefinitionDefaultSetting::Hide => {
LabelValueDefinitionDefaultSetting::Hide
}
LabelValueDefinitionDefaultSetting::Other(v) => {
LabelValueDefinitionDefaultSetting::Other(v.into_static())
}
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LabelValueDefinitionSeverity<S: BosStr = DefaultStr> {
Inform,
Alert,
None,
Other(S),
}
impl<S: BosStr> LabelValueDefinitionSeverity<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Inform => "inform",
Self::Alert => "alert",
Self::None => "none",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"inform" => Self::Inform,
"alert" => Self::Alert,
"none" => Self::None,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for LabelValueDefinitionSeverity<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for LabelValueDefinitionSeverity<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for LabelValueDefinitionSeverity<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for LabelValueDefinitionSeverity<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for LabelValueDefinitionSeverity<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for LabelValueDefinitionSeverity<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = LabelValueDefinitionSeverity<S::Output>;
fn into_static(self) -> Self::Output {
match self {
LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform,
LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert,
LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None,
LabelValueDefinitionSeverity::Other(v) => {
LabelValueDefinitionSeverity::Other(v.into_static())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct LabelValueDefinitionStrings<S: BosStr = DefaultStr> {
pub description: S,
pub lang: Language,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SelfLabel<S: BosStr = DefaultStr> {
pub val: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SelfLabels<S: BosStr = DefaultStr> {
pub values: Vec<label::SelfLabel<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Label<S> {
fn nsid() -> &'static str {
"com.atproto.label.defs"
}
fn def_name() -> &'static str {
"label"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_label_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.val;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("val"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for LabelValueDefinition<S> {
fn nsid() -> &'static str {
"com.atproto.label.defs"
}
fn def_name() -> &'static str {
"labelValueDefinition"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_label_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.identifier;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("identifier"),
max: 100usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.identifier;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 100usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("identifier"),
max: 100usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for LabelValueDefinitionStrings<S> {
fn nsid() -> &'static str {
"com.atproto.label.defs"
}
fn def_name() -> &'static str {
"labelValueDefinitionStrings"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_label_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.description;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.description;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 10000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("description"),
max: 10000usize,
actual: count,
});
}
}
}
{
let value = &self.name;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("name"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.name;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("name"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SelfLabel<S> {
fn nsid() -> &'static str {
"com.atproto.label.defs"
}
fn def_name() -> &'static str {
"selfLabel"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_label_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.val;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("val"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SelfLabels<S> {
fn nsid() -> &'static str {
"com.atproto.label.defs"
}
fn def_name() -> &'static str {
"selfLabels"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_label_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.values;
#[allow(unused_comparisons)]
if value.len() > 10usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("values"),
max: 10usize,
actual: value.len(),
});
}
}
Ok(())
}
}
pub mod label_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Cts;
type Val;
type Uri;
type Src;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Cts = Unset;
type Val = Unset;
type Uri = Unset;
type Src = Unset;
}
pub struct SetCts<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCts<St> {}
impl<St: State> State for SetCts<St> {
type Cts = Set<members::cts>;
type Val = St::Val;
type Uri = St::Uri;
type Src = St::Src;
}
pub struct SetVal<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVal<St> {}
impl<St: State> State for SetVal<St> {
type Cts = St::Cts;
type Val = Set<members::val>;
type Uri = St::Uri;
type Src = St::Src;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Cts = St::Cts;
type Val = St::Val;
type Uri = Set<members::uri>;
type Src = St::Src;
}
pub struct SetSrc<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSrc<St> {}
impl<St: State> State for SetSrc<St> {
type Cts = St::Cts;
type Val = St::Val;
type Uri = St::Uri;
type Src = Set<members::src>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct cts(());
pub struct val(());
pub struct uri(());
pub struct src(());
}
}
pub struct LabelBuilder<S: BosStr, St: label_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Cid<S>>,
Option<Datetime>,
Option<Datetime>,
Option<bool>,
Option<Bytes>,
Option<Did<S>>,
Option<UriValue<S>>,
Option<S>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Label<S> {
pub fn new() -> LabelBuilder<S, label_state::Empty> {
LabelBuilder::new()
}
}
impl<S: BosStr> LabelBuilder<S, label_state::Empty> {
pub fn new() -> Self {
LabelBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> {
pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> LabelBuilder<S, St>
where
St: label_state::State,
St::Cts: label_state::IsUnset,
{
pub fn cts(
mut self,
value: impl Into<Datetime>,
) -> LabelBuilder<S, label_state::SetCts<St>> {
self._fields.1 = Option::Some(value.into());
LabelBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> {
pub fn exp(mut self, value: impl Into<Option<Datetime>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_exp(mut self, value: Option<Datetime>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> {
pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_neg(mut self, value: Option<bool>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> {
pub fn sig(mut self, value: impl Into<Option<Bytes>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_sig(mut self, value: Option<Bytes>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> LabelBuilder<S, St>
where
St: label_state::State,
St::Src: label_state::IsUnset,
{
pub fn src(
mut self,
value: impl Into<Did<S>>,
) -> LabelBuilder<S, label_state::SetSrc<St>> {
self._fields.5 = Option::Some(value.into());
LabelBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelBuilder<S, St>
where
St: label_state::State,
St::Uri: label_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<S>>,
) -> LabelBuilder<S, label_state::SetUri<St>> {
self._fields.6 = Option::Some(value.into());
LabelBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelBuilder<S, St>
where
St: label_state::State,
St::Val: label_state::IsUnset,
{
pub fn val(
mut self,
value: impl Into<S>,
) -> LabelBuilder<S, label_state::SetVal<St>> {
self._fields.7 = Option::Some(value.into());
LabelBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: label_state::State> LabelBuilder<S, St> {
pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_ver(mut self, value: Option<i64>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> LabelBuilder<S, St>
where
St: label_state::State,
St::Cts: label_state::IsSet,
St::Val: label_state::IsSet,
St::Uri: label_state::IsSet,
St::Src: label_state::IsSet,
{
pub fn build(self) -> Label<S> {
Label {
cid: self._fields.0,
cts: self._fields.1.unwrap(),
exp: self._fields.2,
neg: self._fields.3,
sig: self._fields.4,
src: self._fields.5.unwrap(),
uri: self._fields.6.unwrap(),
val: self._fields.7.unwrap(),
ver: self._fields.8,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Label<S> {
Label {
cid: self._fields.0,
cts: self._fields.1.unwrap(),
exp: self._fields.2,
neg: self._fields.3,
sig: self._fields.4,
src: self._fields.5.unwrap(),
uri: self._fields.6.unwrap(),
val: self._fields.7.unwrap(),
ver: self._fields.8,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_atproto_label_defs() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.atproto.label.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("label"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Metadata tag on an atproto resource (eg, repo or record).",
),
),
required: Some(
vec![
SmolStr::new_static("src"), SmolStr::new_static("uri"),
SmolStr::new_static("val"), SmolStr::new_static("cts")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optionally, CID specifying the specific version of 'uri' resource this label applies to.",
),
),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cts"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Timestamp when this label was created."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("exp"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp at which this label expires (no longer applies).",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("neg"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sig"),
LexObjectProperty::Bytes(LexBytes { ..Default::default() }),
);
map.insert(
SmolStr::new_static("src"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"DID of the actor who created this label.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT URI of the record, repository (account), or other resource that this label applies to.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("val"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The short string name of the value or type of this label.",
),
),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ver"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labelValue"),
LexUserType::String(LexString { ..Default::default() }),
);
map.insert(
SmolStr::new_static("labelValueDefinition"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Declares a label value and its expected interpretations and behaviors.",
),
),
required: Some(
vec![
SmolStr::new_static("identifier"),
SmolStr::new_static("severity"),
SmolStr::new_static("blurs"), SmolStr::new_static("locales")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("adultOnly"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blurs"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"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.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("defaultSetting"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("The default setting for this label."),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("identifier"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
),
),
max_length: Some(100usize),
max_graphemes: Some(100usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("locales"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#labelValueDefinitionStrings"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("severity"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("labelValueDefinitionStrings"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Strings which describe the label in the UI, localized into a specific language.",
),
),
required: Some(
vec![
SmolStr::new_static("lang"), SmolStr::new_static("name"),
SmolStr::new_static("description")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"A longer description of what the label means and why it might be applied.",
),
),
max_length: Some(100000usize),
max_graphemes: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The code of the language these strings are written in.",
),
),
format: Some(LexStringFormat::Language),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"A short human-readable name for the label.",
),
),
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("selfLabel"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.",
),
),
required: Some(vec![SmolStr::new_static("val")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("val"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The short string name of the value or type of this label.",
),
),
max_length: Some(128usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("selfLabels"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Metadata tags on an atproto record, published by the author within the record.",
),
),
required: Some(vec![SmolStr::new_static("values")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("values"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#selfLabel"),
..Default::default()
}),
max_length: Some(10usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod label_value_definition_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Blurs;
type Identifier;
type Locales;
type Severity;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blurs = Unset;
type Identifier = Unset;
type Locales = Unset;
type Severity = Unset;
}
pub struct SetBlurs<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlurs<St> {}
impl<St: State> State for SetBlurs<St> {
type Blurs = Set<members::blurs>;
type Identifier = St::Identifier;
type Locales = St::Locales;
type Severity = St::Severity;
}
pub struct SetIdentifier<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIdentifier<St> {}
impl<St: State> State for SetIdentifier<St> {
type Blurs = St::Blurs;
type Identifier = Set<members::identifier>;
type Locales = St::Locales;
type Severity = St::Severity;
}
pub struct SetLocales<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLocales<St> {}
impl<St: State> State for SetLocales<St> {
type Blurs = St::Blurs;
type Identifier = St::Identifier;
type Locales = Set<members::locales>;
type Severity = St::Severity;
}
pub struct SetSeverity<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeverity<St> {}
impl<St: State> State for SetSeverity<St> {
type Blurs = St::Blurs;
type Identifier = St::Identifier;
type Locales = St::Locales;
type Severity = Set<members::severity>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blurs(());
pub struct identifier(());
pub struct locales(());
pub struct severity(());
}
}
pub struct LabelValueDefinitionBuilder<
S: BosStr,
St: label_value_definition_state::State,
> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<LabelValueDefinitionBlurs<S>>,
Option<LabelValueDefinitionDefaultSetting<S>>,
Option<S>,
Option<Vec<label::LabelValueDefinitionStrings<S>>>,
Option<LabelValueDefinitionSeverity<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> LabelValueDefinition<S> {
pub fn new() -> LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> {
LabelValueDefinitionBuilder::new()
}
}
impl<S: BosStr> LabelValueDefinitionBuilder<S, label_value_definition_state::Empty> {
pub fn new() -> Self {
LabelValueDefinitionBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<
S: BosStr,
St: label_value_definition_state::State,
> LabelValueDefinitionBuilder<S, St> {
pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St>
where
St: label_value_definition_state::State,
St::Blurs: label_value_definition_state::IsUnset,
{
pub fn blurs(
mut self,
value: impl Into<LabelValueDefinitionBlurs<S>>,
) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetBlurs<St>> {
self._fields.1 = Option::Some(value.into());
LabelValueDefinitionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<
S: BosStr,
St: label_value_definition_state::State,
> LabelValueDefinitionBuilder<S, St> {
pub fn default_setting(
mut self,
value: impl Into<Option<LabelValueDefinitionDefaultSetting<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_default_setting(
mut self,
value: Option<LabelValueDefinitionDefaultSetting<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St>
where
St: label_value_definition_state::State,
St::Identifier: label_value_definition_state::IsUnset,
{
pub fn identifier(
mut self,
value: impl Into<S>,
) -> LabelValueDefinitionBuilder<
S,
label_value_definition_state::SetIdentifier<St>,
> {
self._fields.3 = Option::Some(value.into());
LabelValueDefinitionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St>
where
St: label_value_definition_state::State,
St::Locales: label_value_definition_state::IsUnset,
{
pub fn locales(
mut self,
value: impl Into<Vec<label::LabelValueDefinitionStrings<S>>>,
) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetLocales<St>> {
self._fields.4 = Option::Some(value.into());
LabelValueDefinitionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St>
where
St: label_value_definition_state::State,
St::Severity: label_value_definition_state::IsUnset,
{
pub fn severity(
mut self,
value: impl Into<LabelValueDefinitionSeverity<S>>,
) -> LabelValueDefinitionBuilder<S, label_value_definition_state::SetSeverity<St>> {
self._fields.5 = Option::Some(value.into());
LabelValueDefinitionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionBuilder<S, St>
where
St: label_value_definition_state::State,
St::Blurs: label_value_definition_state::IsSet,
St::Identifier: label_value_definition_state::IsSet,
St::Locales: label_value_definition_state::IsSet,
St::Severity: label_value_definition_state::IsSet,
{
pub fn build(self) -> LabelValueDefinition<S> {
LabelValueDefinition {
adult_only: self._fields.0,
blurs: self._fields.1.unwrap(),
default_setting: self._fields.2,
identifier: self._fields.3.unwrap(),
locales: self._fields.4.unwrap(),
severity: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> LabelValueDefinition<S> {
LabelValueDefinition {
adult_only: self._fields.0,
blurs: self._fields.1.unwrap(),
default_setting: self._fields.2,
identifier: self._fields.3.unwrap(),
locales: self._fields.4.unwrap(),
severity: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod label_value_definition_strings_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Description;
type Lang;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Description = Unset;
type Lang = Unset;
type Name = Unset;
}
pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDescription<St> {}
impl<St: State> State for SetDescription<St> {
type Description = Set<members::description>;
type Lang = St::Lang;
type Name = St::Name;
}
pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLang<St> {}
impl<St: State> State for SetLang<St> {
type Description = St::Description;
type Lang = Set<members::lang>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Description = St::Description;
type Lang = St::Lang;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct description(());
pub struct lang(());
pub struct name(());
}
}
pub struct LabelValueDefinitionStringsBuilder<
S: BosStr,
St: label_value_definition_strings_state::State,
> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<Language>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> LabelValueDefinitionStrings<S> {
pub fn new() -> LabelValueDefinitionStringsBuilder<
S,
label_value_definition_strings_state::Empty,
> {
LabelValueDefinitionStringsBuilder::new()
}
}
impl<
S: BosStr,
> LabelValueDefinitionStringsBuilder<S, label_value_definition_strings_state::Empty> {
pub fn new() -> Self {
LabelValueDefinitionStringsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St>
where
St: label_value_definition_strings_state::State,
St::Description: label_value_definition_strings_state::IsUnset,
{
pub fn description(
mut self,
value: impl Into<S>,
) -> LabelValueDefinitionStringsBuilder<
S,
label_value_definition_strings_state::SetDescription<St>,
> {
self._fields.0 = Option::Some(value.into());
LabelValueDefinitionStringsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St>
where
St: label_value_definition_strings_state::State,
St::Lang: label_value_definition_strings_state::IsUnset,
{
pub fn lang(
mut self,
value: impl Into<Language>,
) -> LabelValueDefinitionStringsBuilder<
S,
label_value_definition_strings_state::SetLang<St>,
> {
self._fields.1 = Option::Some(value.into());
LabelValueDefinitionStringsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St>
where
St: label_value_definition_strings_state::State,
St::Name: label_value_definition_strings_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> LabelValueDefinitionStringsBuilder<
S,
label_value_definition_strings_state::SetName<St>,
> {
self._fields.2 = Option::Some(value.into());
LabelValueDefinitionStringsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LabelValueDefinitionStringsBuilder<S, St>
where
St: label_value_definition_strings_state::State,
St::Description: label_value_definition_strings_state::IsSet,
St::Lang: label_value_definition_strings_state::IsSet,
St::Name: label_value_definition_strings_state::IsSet,
{
pub fn build(self) -> LabelValueDefinitionStrings<S> {
LabelValueDefinitionStrings {
description: self._fields.0.unwrap(),
lang: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> LabelValueDefinitionStrings<S> {
LabelValueDefinitionStrings {
description: self._fields.0.unwrap(),
lang: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod self_labels_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Values;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Values = Unset;
}
pub struct SetValues<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValues<St> {}
impl<St: State> State for SetValues<St> {
type Values = Set<members::values>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct values(());
}
}
pub struct SelfLabelsBuilder<S: BosStr, St: self_labels_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<label::SelfLabel<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SelfLabels<S> {
pub fn new() -> SelfLabelsBuilder<S, self_labels_state::Empty> {
SelfLabelsBuilder::new()
}
}
impl<S: BosStr> SelfLabelsBuilder<S, self_labels_state::Empty> {
pub fn new() -> Self {
SelfLabelsBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SelfLabelsBuilder<S, St>
where
St: self_labels_state::State,
St::Values: self_labels_state::IsUnset,
{
pub fn values(
mut self,
value: impl Into<Vec<label::SelfLabel<S>>>,
) -> SelfLabelsBuilder<S, self_labels_state::SetValues<St>> {
self._fields.0 = Option::Some(value.into());
SelfLabelsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SelfLabelsBuilder<S, St>
where
St: self_labels_state::State,
St::Values: self_labels_state::IsSet,
{
pub fn build(self) -> SelfLabels<S> {
SelfLabels {
values: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> SelfLabels<S> {
SelfLabels {
values: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}