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::{CowStr, BosStr, 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::{Did, AtUri, Cid};
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::zone_stratos;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Source<S: BosStr = DefaultStr> {
pub service: Did<S>,
pub subject: zone_stratos::SubjectRef<S>,
pub vary: SourceVary<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 SourceVary<S: BosStr = DefaultStr> {
Authenticated,
Unauthenticated,
Other(S),
}
impl<S: BosStr> SourceVary<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Authenticated => "authenticated",
Self::Unauthenticated => "unauthenticated",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"authenticated" => Self::Authenticated,
"unauthenticated" => Self::Unauthenticated,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for SourceVary<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for SourceVary<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for SourceVary<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 SourceVary<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 SourceVary<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for SourceVary<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = SourceVary<S::Output>;
fn into_static(self) -> Self::Output {
match self {
SourceVary::Authenticated => SourceVary::Authenticated,
SourceVary::Unauthenticated => SourceVary::Unauthenticated,
SourceVary::Other(v) => SourceVary::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SubjectRef<S: BosStr = DefaultStr> {
pub cid: Cid<S>,
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Source<S> {
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 <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("vary"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for SubjectRef<S> {
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(())
}
}
pub mod source_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 Subject;
type Vary;
type Service;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Subject = Unset;
type Vary = Unset;
type Service = Unset;
}
pub struct SetSubject<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSubject<St> {}
impl<St: State> State for SetSubject<St> {
type Subject = Set<members::subject>;
type Vary = St::Vary;
type Service = St::Service;
}
pub struct SetVary<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVary<St> {}
impl<St: State> State for SetVary<St> {
type Subject = St::Subject;
type Vary = Set<members::vary>;
type Service = St::Service;
}
pub struct SetService<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetService<St> {}
impl<St: State> State for SetService<St> {
type Subject = St::Subject;
type Vary = St::Vary;
type Service = Set<members::service>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct subject(());
pub struct vary(());
pub struct service(());
}
}
pub struct SourceBuilder<S: BosStr, St: source_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<zone_stratos::SubjectRef<S>>,
Option<SourceVary<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Source<S> {
pub fn new() -> SourceBuilder<S, source_state::Empty> {
SourceBuilder::new()
}
}
impl<S: BosStr> SourceBuilder<S, source_state::Empty> {
pub fn new() -> Self {
SourceBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SourceBuilder<S, St>
where
St: source_state::State,
St::Service: source_state::IsUnset,
{
pub fn service(
mut self,
value: impl Into<Did<S>>,
) -> SourceBuilder<S, source_state::SetService<St>> {
self._fields.0 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SourceBuilder<S, St>
where
St: source_state::State,
St::Subject: source_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<zone_stratos::SubjectRef<S>>,
) -> SourceBuilder<S, source_state::SetSubject<St>> {
self._fields.1 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SourceBuilder<S, St>
where
St: source_state::State,
St::Vary: source_state::IsUnset,
{
pub fn vary(
mut self,
value: impl Into<SourceVary<S>>,
) -> SourceBuilder<S, source_state::SetVary<St>> {
self._fields.2 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SourceBuilder<S, St>
where
St: source_state::State,
St::Subject: source_state::IsSet,
St::Vary: source_state::IsSet,
St::Service: source_state::IsSet,
{
pub fn build(self) -> Source<S> {
Source {
service: self._fields.0.unwrap(),
subject: self._fields.1.unwrap(),
vary: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Source<S> {
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> {
#[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("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()
}
}
pub mod subject_ref_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 Uri;
type Cid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Cid = Unset;
}
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 Uri = Set<members::uri>;
type Cid = St::Cid;
}
pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCid<St> {}
impl<St: State> State for SetCid<St> {
type Uri = St::Uri;
type Cid = Set<members::cid>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct cid(());
}
}
pub struct SubjectRefBuilder<S: BosStr, St: subject_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Cid<S>>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> SubjectRef<S> {
pub fn new() -> SubjectRefBuilder<S, subject_ref_state::Empty> {
SubjectRefBuilder::new()
}
}
impl<S: BosStr> SubjectRefBuilder<S, subject_ref_state::Empty> {
pub fn new() -> Self {
SubjectRefBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubjectRefBuilder<S, St>
where
St: subject_ref_state::State,
St::Cid: subject_ref_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<S>>,
) -> SubjectRefBuilder<S, subject_ref_state::SetCid<St>> {
self._fields.0 = Option::Some(value.into());
SubjectRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubjectRefBuilder<S, St>
where
St: subject_ref_state::State,
St::Uri: subject_ref_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> SubjectRefBuilder<S, subject_ref_state::SetUri<St>> {
self._fields.1 = Option::Some(value.into());
SubjectRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SubjectRefBuilder<S, St>
where
St: subject_ref_state::State,
St::Uri: subject_ref_state::IsSet,
St::Cid: subject_ref_state::IsSet,
{
pub fn build(self) -> SubjectRef<S> {
SubjectRef {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> SubjectRef<S> {
SubjectRef {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}