// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: zone.stratos.defs // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. //! Generated bindings for the `zone.stratos` Lexicon namespace/module. pub mod actor; pub mod boundary; pub mod enrollment; pub mod feed; pub mod identity; pub mod repo; pub mod sync; #[allow(unused_imports)] use alloc::collections::BTreeMap; #[allow(unused_imports)] use core::marker::PhantomData; use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr}; #[allow(unused_imports)] use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation; use jacquard_common::deps::smol_str::SmolStr; use jacquard_common::types::string::{AtUri, Cid, Did}; use jacquard_common::types::value::Data; use jacquard_derive::IntoStatic; use jacquard_lexicon::lexicon::LexiconDoc; use jacquard_lexicon::schema::LexiconSchema; use crate::zone_stratos; #[allow(unused_imports)] use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; use serde::{Deserialize, Serialize}; /// Indicates this record requires hydration from an external service. The stub record on the PDS contains minimal data; full content is fetched from the service endpoint. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct Source { /// DID of the hydration service, optionally with fragment identifying the service entry (e.g., 'did:plc:abc123#atproto_pns'). pub service: Did, /// Reference to the full record at the hydration service. pub subject: zone_stratos::SubjectRef, /// Indicates when hydration is needed. 'authenticated' means full content requires viewer authentication. pub vary: SourceVary, #[serde( flatten, default, deserialize_with = "deserialize_source_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// Indicates when hydration is needed. 'authenticated' means full content requires viewer authentication. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum SourceVary { Authenticated, Unauthenticated, Other(S), } impl SourceVary { pub fn as_str(&self) -> &str { match self { Self::Authenticated => "authenticated", Self::Unauthenticated => "unauthenticated", Self::Other(s) => s.as_ref(), } } /// Construct from a string-like value, matching known values. pub fn from_value(s: S) -> Self { match s.as_ref() { "authenticated" => Self::Authenticated, "unauthenticated" => Self::Unauthenticated, _ => Self::Other(s), } } } impl core::fmt::Display for SourceVary { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", self.as_str()) } } impl AsRef for SourceVary { fn as_ref(&self) -> &str { self.as_str() } } impl Serialize for SourceVary { fn serialize(&self, serializer: Ser) -> Result where Ser: serde::Serializer, { serializer.serialize_str(self.as_str()) } } impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for SourceVary { fn deserialize(deserializer: D) -> Result where D: serde::Deserializer<'de>, { let s = S::deserialize(deserializer)?; Ok(Self::from_value(s)) } } impl Default for SourceVary { fn default() -> Self { Self::Other(Default::default()) } } impl jacquard_common::IntoStatic for SourceVary where S: BosStr + jacquard_common::IntoStatic, S::Output: BosStr, { type Output = SourceVary; fn into_static(self) -> Self::Output { match self { SourceVary::Authenticated => SourceVary::Authenticated, SourceVary::Unauthenticated => SourceVary::Unauthenticated, SourceVary::Other(v) => SourceVary::Other(v.into_static()), } } } /// A strong reference to a record, including its content hash for verification. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct SubjectRef { /// CID of the full record content for integrity verification. pub cid: Cid, /// AT-URI of the record at the hydration service. pub uri: AtUri, #[serde( flatten, default, deserialize_with = "deserialize_subject_ref_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } impl LexiconSchema for Source { fn nsid() -> &'static str { "zone.stratos.defs" } fn def_name() -> &'static str { "source" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_zone_stratos_defs() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.vary; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 128usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("vary"), max: 128usize, actual: ::len(value.as_ref()), }); } } Ok(()) } } impl LexiconSchema for SubjectRef { fn nsid() -> &'static str { "zone.stratos.defs" } fn def_name() -> &'static str { "subjectRef" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_zone_stratos_defs() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } fn deserialize_source_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod source_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[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 { type Service; type Subject; type Vary; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Service = Unset; type Subject = Unset; type Vary = Unset; } ///State transition - sets the `service` field to Set pub struct SetService(PhantomData St>); impl sealed::Sealed for SetService {} impl State for SetService { type Service = Set; type Subject = St::Subject; type Vary = St::Vary; } ///State transition - sets the `subject` field to Set pub struct SetSubject(PhantomData St>); impl sealed::Sealed for SetSubject {} impl State for SetSubject { type Service = St::Service; type Subject = Set; type Vary = St::Vary; } ///State transition - sets the `vary` field to Set pub struct SetVary(PhantomData St>); impl sealed::Sealed for SetVary {} impl State for SetVary { type Service = St::Service; type Subject = St::Subject; type Vary = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `service` field pub struct service(()); ///Marker type for the `subject` field pub struct subject(()); ///Marker type for the `vary` field pub struct vary(()); } } /// Builder for constructing an instance of this type. pub struct SourceBuilder { _state: PhantomData St>, _fields: ( Option>, Option>, Option>, ), _type: PhantomData S>, } impl Source { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SourceBuilder { SourceBuilder::new() } } impl Source { /// Create a new builder for this type pub fn builder() -> SourceBuilder { SourceBuilder::builder() } } impl SourceBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SourceBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl SourceBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SourceBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl SourceBuilder where St: source_state::State, St::Service: source_state::IsUnset, { /// Set the `service` field (required) pub fn service( mut self, value: impl Into>, ) -> SourceBuilder, S> { self._fields.0 = Option::Some(value.into()); SourceBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SourceBuilder where St: source_state::State, St::Subject: source_state::IsUnset, { /// Set the `subject` field (required) pub fn subject( mut self, value: impl Into>, ) -> SourceBuilder, S> { self._fields.1 = Option::Some(value.into()); SourceBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SourceBuilder where St: source_state::State, St::Vary: source_state::IsUnset, { /// Set the `vary` field (required) pub fn vary( mut self, value: impl Into>, ) -> SourceBuilder, S> { self._fields.2 = Option::Some(value.into()); SourceBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SourceBuilder where St: source_state::State, St::Service: source_state::IsSet, St::Subject: source_state::IsSet, St::Vary: source_state::IsSet, { /// Build the final struct. pub fn build(self) -> Source { Source { service: self._fields.0.unwrap(), subject: self._fields.1.unwrap(), vary: self._fields.2.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Source { Source { service: self._fields.0.unwrap(), subject: self._fields.1.unwrap(), vary: self._fields.2.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_zone_stratos_defs() -> LexiconDoc<'static> { use alloc::collections::BTreeMap; #[allow(unused_imports)] use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType}; use jacquard_lexicon::lexicon::*; LexiconDoc { lexicon: Lexicon::Lexicon1, id: CowStr::new_static("zone.stratos.defs"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("source"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "Indicates this record requires hydration from an external service. The stub record on the PDS contains minimal data; full content is fetched from the service endpoint.", ), ), required: Some( vec![ SmolStr::new_static("vary"), SmolStr::new_static("subject"), SmolStr::new_static("service") ], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("service"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "DID of the hydration service, optionally with fragment identifying the service entry (e.g., 'did:plc:abc123#atproto_pns').", ), ), format: Some(LexStringFormat::Did), ..Default::default() }), ); map.insert( SmolStr::new_static("subject"), LexObjectProperty::Ref(LexRef { r#ref: CowStr::new_static("#subjectRef"), ..Default::default() }), ); map.insert( SmolStr::new_static("vary"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "Indicates when hydration is needed. 'authenticated' means full content requires viewer authentication.", ), ), max_length: Some(128usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("subjectRef"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A strong reference to a record, including its content hash for verification.", ), ), required: Some( vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")], ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("cid"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "CID of the full record content for integrity verification.", ), ), format: Some(LexStringFormat::Cid), ..Default::default() }), ); map.insert( SmolStr::new_static("uri"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "AT-URI of the record at the hydration service.", ), ), format: Some(LexStringFormat::AtUri), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } } fn deserialize_subject_ref_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod subject_ref_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[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 { type Cid; type Uri; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Cid = Unset; type Uri = Unset; } ///State transition - sets the `cid` field to Set pub struct SetCid(PhantomData St>); impl sealed::Sealed for SetCid {} impl State for SetCid { type Cid = Set; type Uri = St::Uri; } ///State transition - sets the `uri` field to Set pub struct SetUri(PhantomData St>); impl sealed::Sealed for SetUri {} impl State for SetUri { type Cid = St::Cid; type Uri = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `cid` field pub struct cid(()); ///Marker type for the `uri` field pub struct uri(()); } } /// Builder for constructing an instance of this type. pub struct SubjectRefBuilder { _state: PhantomData St>, _fields: (Option>, Option>), _type: PhantomData S>, } impl SubjectRef { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> SubjectRefBuilder { SubjectRefBuilder::new() } } impl SubjectRef { /// Create a new builder for this type pub fn builder() -> SubjectRefBuilder { SubjectRefBuilder::builder() } } impl SubjectRefBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { SubjectRefBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl SubjectRefBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { SubjectRefBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl SubjectRefBuilder where St: subject_ref_state::State, St::Cid: subject_ref_state::IsUnset, { /// Set the `cid` field (required) pub fn cid( mut self, value: impl Into>, ) -> SubjectRefBuilder, S> { self._fields.0 = Option::Some(value.into()); SubjectRefBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SubjectRefBuilder where St: subject_ref_state::State, St::Uri: subject_ref_state::IsUnset, { /// Set the `uri` field (required) pub fn uri( mut self, value: impl Into>, ) -> SubjectRefBuilder, S> { self._fields.1 = Option::Some(value.into()); SubjectRefBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl SubjectRefBuilder where St: subject_ref_state::State, St::Cid: subject_ref_state::IsSet, St::Uri: subject_ref_state::IsSet, { /// Build the final struct. pub fn build(self) -> SubjectRef { SubjectRef { cid: self._fields.0.unwrap(), uri: self._fields.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> SubjectRef { SubjectRef { cid: self._fields.0.unwrap(), uri: self._fields.1.unwrap(), extra_data: Some(extra_data), } } }