// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.actor.profile // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// A declaration of a Weaver account profile. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Profile<'a> { /// Small image to be displayed next to posts from account. AKA, 'profile picture' #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub avatar: std::option::Option>, /// Larger horizontal image to display behind profile view. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub banner: std::option::Option>, /// Include link to this account on Bluesky. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub bluesky: std::option::Option, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub created_at: std::option::Option, /// Free-form profile description text. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub display_name: std::option::Option>, /// Self-label values, specific to the application, on the overall account. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub labels: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub links: std::option::Option>>, /// Free-form location text. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub location: std::option::Option>, /// Notebooks or other records pinned for display. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub pinned: std::option::Option>, /// Pronouns to use in user-generated content. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub pronouns: std::option::Option>, /// Include link to this account on stream.place. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub streamplace: std::option::Option, /// Include link to this account on Tangled. #[serde(skip_serializing_if = "std::option::Option::is_none")] pub tangled: std::option::Option, } pub mod profile_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed {} /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty {} /// Marker types for field names #[allow(non_camel_case_types)] pub mod members {} } /// Builder for constructing an instance of this type pub struct ProfileBuilder<'a, S: profile_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Profile<'a> { /// Create a new builder for this type pub fn new() -> ProfileBuilder<'a, profile_state::Empty> { ProfileBuilder::new() } } impl<'a> ProfileBuilder<'a, profile_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ProfileBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: ( None, None, None, None, None, None, None, None, None, None, None, None, None, ), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `avatar` field (optional) pub fn avatar( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `avatar` field to an Option value (optional) pub fn maybe_avatar( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `banner` field (optional) pub fn banner( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `banner` field to an Option value (optional) pub fn maybe_banner( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `bluesky` field (optional) pub fn bluesky(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `bluesky` field to an Option value (optional) pub fn maybe_bluesky(mut self, value: Option) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `createdAt` field (optional) pub fn created_at( mut self, value: impl Into>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `createdAt` field to an Option value (optional) pub fn maybe_created_at( mut self, value: Option, ) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `displayName` field (optional) pub fn display_name( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `displayName` field to an Option value (optional) pub fn maybe_display_name( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `labels` field (optional) pub fn labels( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.6 = value.into(); self } /// Set the `labels` field to an Option value (optional) pub fn maybe_labels( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.6 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `links` field (optional) pub fn links( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.7 = value.into(); self } /// Set the `links` field to an Option value (optional) pub fn maybe_links( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.7 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `location` field (optional) pub fn location( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.8 = value.into(); self } /// Set the `location` field to an Option value (optional) pub fn maybe_location(mut self, value: Option>) -> Self { self.__unsafe_private_named.8 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `pinned` field (optional) pub fn pinned( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.9 = value.into(); self } /// Set the `pinned` field to an Option value (optional) pub fn maybe_pinned( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.9 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `pronouns` field (optional) pub fn pronouns( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.10 = value.into(); self } /// Set the `pronouns` field to an Option value (optional) pub fn maybe_pronouns( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.10 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `streamplace` field (optional) pub fn streamplace(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.11 = value.into(); self } /// Set the `streamplace` field to an Option value (optional) pub fn maybe_streamplace(mut self, value: Option) -> Self { self.__unsafe_private_named.11 = value; self } } impl<'a, S: profile_state::State> ProfileBuilder<'a, S> { /// Set the `tangled` field (optional) pub fn tangled(mut self, value: impl Into>) -> Self { self.__unsafe_private_named.12 = value.into(); self } /// Set the `tangled` field to an Option value (optional) pub fn maybe_tangled(mut self, value: Option) -> Self { self.__unsafe_private_named.12 = value; self } } impl<'a, S> ProfileBuilder<'a, S> where S: profile_state::State, { /// Build the final struct pub fn build(self) -> Profile<'a> { Profile { avatar: self.__unsafe_private_named.0, banner: self.__unsafe_private_named.1, bluesky: self.__unsafe_private_named.2, created_at: self.__unsafe_private_named.3, description: self.__unsafe_private_named.4, display_name: self.__unsafe_private_named.5, labels: self.__unsafe_private_named.6, links: self.__unsafe_private_named.7, location: self.__unsafe_private_named.8, pinned: self.__unsafe_private_named.9, pronouns: self.__unsafe_private_named.10, streamplace: self.__unsafe_private_named.11, tangled: self.__unsafe_private_named.12, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Profile<'a> { Profile { avatar: self.__unsafe_private_named.0, banner: self.__unsafe_private_named.1, bluesky: self.__unsafe_private_named.2, created_at: self.__unsafe_private_named.3, description: self.__unsafe_private_named.4, display_name: self.__unsafe_private_named.5, labels: self.__unsafe_private_named.6, links: self.__unsafe_private_named.7, location: self.__unsafe_private_named.8, pinned: self.__unsafe_private_named.9, pronouns: self.__unsafe_private_named.10, streamplace: self.__unsafe_private_named.11, tangled: self.__unsafe_private_named.12, extra_data: Some(extra_data), } } } impl<'a> Profile<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, ProfileRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) } } /// Typed wrapper for GetRecord response with this collection's record type. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct ProfileGetRecordOutput<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cid: std::option::Option>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, #[serde(borrow)] pub value: Profile<'a>, } impl From> for Profile<'_> { fn from(output: ProfileGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Profile<'_> { const NSID: &'static str = "sh.weaver.actor.profile"; type Record = ProfileRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct ProfileRecord; impl jacquard_common::xrpc::XrpcResp for ProfileRecord { const NSID: &'static str = "sh.weaver.actor.profile"; const ENCODING: &'static str = "application/json"; type Output<'de> = ProfileGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for ProfileRecord { const NSID: &'static str = "sh.weaver.actor.profile"; type Record = ProfileRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Profile<'a> { fn nsid() -> &'static str { "sh.weaver.actor.profile" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_actor_profile() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10240usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 10240usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.description { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 1024usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 1024usize, actual: count, }); } } } if let Some(ref value) = self.display_name { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 640usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "display_name", ), max: 640usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.display_name { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 64usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "display_name", ), max: 64usize, actual: count, }); } } } if let Some(ref value) = self.links { #[allow(unused_comparisons)] if value.len() > 5usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "links", ), max: 5usize, actual: value.len(), }); } } if let Some(ref value) = self.links { #[allow(unused_comparisons)] if value.len() < 0usize { return Err(::jacquard_lexicon::validation::ConstraintError::MinLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "links", ), min: 0usize, actual: value.len(), }); } } if let Some(ref value) = self.location { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 400usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "location", ), max: 400usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.location { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 40usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "location", ), max: 40usize, actual: count, }); } } } Ok(()) } } fn lexicon_doc_sh_weaver_actor_profile() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("sh.weaver.actor.profile"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { description: Some( ::jacquard_common::CowStr::new_static( "A declaration of a Weaver account profile.", ), ), key: Some(::jacquard_common::CowStr::new_static("literal:self")), record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("avatar"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("banner"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("bluesky"), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "createdAt", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Datetime, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Free-form profile description text.", ), ), format: None, default: None, min_length: None, max_length: Some(10240usize), min_graphemes: None, max_graphemes: Some(1024usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "displayName", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(640usize), min_graphemes: None, max_graphemes: Some(64usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("labels"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: Some( ::jacquard_common::CowStr::new_static( "Self-label values, specific to the application, on the overall account.", ), ), refs: vec![ ::jacquard_common::CowStr::new_static("com.atproto.label.defs#selfLabels") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("links"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Any URI, intended for social profiles or websites, can be used to link DIDs/AT-URIs too.", ), ), format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Uri, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), min_length: Some(0usize), max_length: Some(5usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "location", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Free-form location text.", ), ), format: None, default: None, min_length: None, max_length: Some(400usize), min_graphemes: None, max_graphemes: Some(40usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("pinned"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#pinnedList", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "pronouns", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "sh.weaver.actor.defs#pronounsList", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "streamplace", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("tangled"), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map }, }), }), ); map }, } }