pub mod actor;
pub mod boundary;
pub mod enrollment;
pub mod feed;
pub mod repo;
pub mod sync;
#[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, AtUri, Cid};
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::zone_stratos;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Source<'a> {
#[serde(borrow)]
pub service: Did<'a>,
#[serde(borrow)]
pub subject: zone_stratos::SubjectRef<'a>,
#[serde(borrow)]
pub vary: SourceVary<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SourceVary<'a> {
Authenticated,
Unauthenticated,
Other(CowStr<'a>),
}
impl<'a> SourceVary<'a> {
pub fn as_str(&self) -> &str {
match self {
Self::Authenticated => "authenticated",
Self::Unauthenticated => "unauthenticated",
Self::Other(s) => s.as_ref(),
}
}
}
impl<'a> From<&'a str> for SourceVary<'a> {
fn from(s: &'a str) -> Self {
match s {
"authenticated" => Self::Authenticated,
"unauthenticated" => Self::Unauthenticated,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for SourceVary<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"authenticated" => Self::Authenticated,
"unauthenticated" => Self::Unauthenticated,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for SourceVary<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for SourceVary<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for SourceVary<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for SourceVary<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for SourceVary<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for SourceVary<'_> {
type Output = SourceVary<'static>;
fn into_static(self) -> Self::Output {
match self {
SourceVary::Authenticated => SourceVary::Authenticated,
SourceVary::Unauthenticated => SourceVary::Unauthenticated,
SourceVary::Other(v) => SourceVary::Other(v.into_static()),
}
}
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SubjectRef<'a> {
#[serde(borrow)]
pub cid: Cid<'a>,
#[serde(borrow)]
pub uri: AtUri<'a>,
}
impl<'a> LexiconSchema for Source<'a> {
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<'a> LexiconSchema for SubjectRef<'a> {
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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSubject<S> {}
impl<S: State> State for SetSubject<S> {
type Subject = Set<members::subject>;
type Vary = S::Vary;
type Service = S::Service;
}
pub struct SetVary<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetVary<S> {}
impl<S: State> State for SetVary<S> {
type Subject = S::Subject;
type Vary = Set<members::vary>;
type Service = S::Service;
}
pub struct SetService<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetService<S> {}
impl<S: State> State for SetService<S> {
type Subject = S::Subject;
type Vary = S::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<'a, S: source_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Did<'a>>,
Option<zone_stratos::SubjectRef<'a>>,
Option<SourceVary<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Source<'a> {
pub fn new() -> SourceBuilder<'a, source_state::Empty> {
SourceBuilder::new()
}
}
impl<'a> SourceBuilder<'a, source_state::Empty> {
pub fn new() -> Self {
SourceBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SourceBuilder<'a, S>
where
S: source_state::State,
S::Service: source_state::IsUnset,
{
pub fn service(
mut self,
value: impl Into<Did<'a>>,
) -> SourceBuilder<'a, source_state::SetService<S>> {
self._fields.0 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SourceBuilder<'a, S>
where
S: source_state::State,
S::Subject: source_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<zone_stratos::SubjectRef<'a>>,
) -> SourceBuilder<'a, source_state::SetSubject<S>> {
self._fields.1 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SourceBuilder<'a, S>
where
S: source_state::State,
S::Vary: source_state::IsUnset,
{
pub fn vary(
mut self,
value: impl Into<SourceVary<'a>>,
) -> SourceBuilder<'a, source_state::SetVary<S>> {
self._fields.2 = Option::Some(value.into());
SourceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SourceBuilder<'a, S>
where
S: source_state::State,
S::Subject: source_state::IsSet,
S::Vary: source_state::IsSet,
S::Service: source_state::IsSet,
{
pub fn build(self) -> Source<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Source<'a> {
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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
type Cid = S::Cid;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Uri = S::Uri;
type Cid = Set<members::cid>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct cid(());
}
}
pub struct SubjectRefBuilder<'a, S: subject_ref_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Cid<'a>>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> SubjectRef<'a> {
pub fn new() -> SubjectRefBuilder<'a, subject_ref_state::Empty> {
SubjectRefBuilder::new()
}
}
impl<'a> SubjectRefBuilder<'a, subject_ref_state::Empty> {
pub fn new() -> Self {
SubjectRefBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubjectRefBuilder<'a, S>
where
S: subject_ref_state::State,
S::Cid: subject_ref_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<Cid<'a>>,
) -> SubjectRefBuilder<'a, subject_ref_state::SetCid<S>> {
self._fields.0 = Option::Some(value.into());
SubjectRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubjectRefBuilder<'a, S>
where
S: subject_ref_state::State,
S::Uri: subject_ref_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<'a>>,
) -> SubjectRefBuilder<'a, subject_ref_state::SetUri<S>> {
self._fields.1 = Option::Some(value.into());
SubjectRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SubjectRefBuilder<'a, S>
where
S: subject_ref_state::State,
S::Uri: subject_ref_state::IsSet,
S::Cid: subject_ref_state::IsSet,
{
pub fn build(self) -> SubjectRef<'a> {
SubjectRef {
cid: self._fields.0.unwrap(),
uri: self._fields.1.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>,
>,
) -> SubjectRef<'a> {
SubjectRef {
cid: self._fields.0.unwrap(),
uri: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}