pub mod get_profile;
pub mod list_profiles;
pub mod profile;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, Handle, UriValue};
use jacquard_derive::{IntoStatic, lexicon};
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::app_bsky::richtext::facet::Facet;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ProfileView<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub avatar_alt: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub avatar_url: Option<UriValue<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description_facets: Option<Vec<Facet<'a>>>,
#[serde(borrow)]
pub did: Did<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub display_name: Option<CowStr<'a>>,
#[serde(borrow)]
pub handle: Handle<'a>,
}
impl<'a> LexiconSchema for ProfileView<'a> {
fn nsid() -> &'static str {
"org.passingreads.actor.defs"
}
fn def_name() -> &'static str {
"profileView"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_org_passingreads_actor_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.avatar_alt {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("avatar_alt"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2560usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 2560usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.display_name {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("display_name"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod profile_view_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 Did;
type Handle;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
type Handle = Unset;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Did = Set<members::did>;
type Handle = S::Handle;
}
pub struct SetHandle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHandle<S> {}
impl<S: State> State for SetHandle<S> {
type Did = S::Did;
type Handle = Set<members::handle>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
pub struct handle(());
}
}
pub struct ProfileViewBuilder<'a, S: profile_view_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<UriValue<'a>>,
Option<CowStr<'a>>,
Option<Vec<Facet<'a>>>,
Option<Did<'a>>,
Option<CowStr<'a>>,
Option<Handle<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ProfileView<'a> {
pub fn new() -> ProfileViewBuilder<'a, profile_view_state::Empty> {
ProfileViewBuilder::new()
}
}
impl<'a> ProfileViewBuilder<'a, profile_view_state::Empty> {
pub fn new() -> Self {
ProfileViewBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_view_state::State> ProfileViewBuilder<'a, S> {
pub fn avatar_alt(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_avatar_alt(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: profile_view_state::State> ProfileViewBuilder<'a, S> {
pub fn avatar_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_avatar_url(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: profile_view_state::State> ProfileViewBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: profile_view_state::State> ProfileViewBuilder<'a, S> {
pub fn description_facets(
mut self,
value: impl Into<Option<Vec<Facet<'a>>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_description_facets(mut self, value: Option<Vec<Facet<'a>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> ProfileViewBuilder<'a, S>
where
S: profile_view_state::State,
S::Did: profile_view_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> ProfileViewBuilder<'a, profile_view_state::SetDid<S>> {
self._fields.4 = Option::Some(value.into());
ProfileViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: profile_view_state::State> ProfileViewBuilder<'a, S> {
pub fn display_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_display_name(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S> ProfileViewBuilder<'a, S>
where
S: profile_view_state::State,
S::Handle: profile_view_state::IsUnset,
{
pub fn handle(
mut self,
value: impl Into<Handle<'a>>,
) -> ProfileViewBuilder<'a, profile_view_state::SetHandle<S>> {
self._fields.6 = Option::Some(value.into());
ProfileViewBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ProfileViewBuilder<'a, S>
where
S: profile_view_state::State,
S::Did: profile_view_state::IsSet,
S::Handle: profile_view_state::IsSet,
{
pub fn build(self) -> ProfileView<'a> {
ProfileView {
avatar_alt: self._fields.0,
avatar_url: self._fields.1,
description: self._fields.2,
description_facets: self._fields.3,
did: self._fields.4.unwrap(),
display_name: self._fields.5,
handle: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ProfileView<'a> {
ProfileView {
avatar_alt: self._fields.0,
avatar_url: self._fields.1,
description: self._fields.2,
description_facets: self._fields.3,
did: self._fields.4.unwrap(),
display_name: self._fields.5,
handle: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_org_passingreads_actor_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("org.passingreads.actor.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("profileView"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Profile view of a user for API responses. Based on the actor.profile record but with resolved avatar URL.",
),
),
required: Some(
vec![SmolStr::new_static("did"), SmolStr::new_static("handle")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("avatarAlt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Alt text for the avatar image"),
),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("avatarUrl"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Resolved URL to the avatar image"),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
max_length: Some(2560usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("descriptionFacets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static("Rich text facets for the description"),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("app.bsky.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("displayName"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}