#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
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::sh_tangled::feed::star;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "sh.tangled.feed.star",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Star<S: BosStr = DefaultStr> {
pub created_at: Datetime,
pub subject: StarSubject<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum StarSubject<S: BosStr = DefaultStr> {
#[serde(rename = "sh.tangled.feed.star#repo")]
Repo(Box<star::Repo<S>>),
#[serde(rename = "sh.tangled.feed.star#string")]
String(Box<star::StarString<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct StarGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Star<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Repo<S: BosStr = DefaultStr> {
pub did: Did<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct StarString<S: BosStr = DefaultStr> {
pub uri: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Star<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, StarRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct StarRecord;
impl XrpcResp for StarRecord {
const NSID: &'static str = "sh.tangled.feed.star";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = StarGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<StarGetRecordOutput<S>> for Star<S> {
fn from(output: StarGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Star<S> {
const NSID: &'static str = "sh.tangled.feed.star";
type Record = StarRecord;
}
impl Collection for StarRecord {
const NSID: &'static str = "sh.tangled.feed.star";
type Record = StarRecord;
}
impl<S: BosStr> LexiconSchema for Star<S> {
fn nsid() -> &'static str {
"sh.tangled.feed.star"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_feed_star()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Repo<S> {
fn nsid() -> &'static str {
"sh.tangled.feed.star"
}
fn def_name() -> &'static str {
"repo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_feed_star()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for StarString<S> {
fn nsid() -> &'static str {
"sh.tangled.feed.star"
}
fn def_name() -> &'static str {
"string"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_feed_star()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod star_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 CreatedAt;
type Subject;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type Subject = Unset;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type CreatedAt = Set<members::created_at>;
type Subject = St::Subject;
}
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 CreatedAt = St::CreatedAt;
type Subject = Set<members::subject>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct subject(());
}
}
pub struct StarBuilder<St: star_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Datetime>, Option<StarSubject<S>>),
_type: PhantomData<fn() -> S>,
}
impl Star<DefaultStr> {
pub fn new() -> StarBuilder<star_state::Empty, DefaultStr> {
StarBuilder::new()
}
}
impl<S: BosStr> Star<S> {
pub fn builder() -> StarBuilder<star_state::Empty, S> {
StarBuilder::builder()
}
}
impl StarBuilder<star_state::Empty, DefaultStr> {
pub fn new() -> Self {
StarBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> StarBuilder<star_state::Empty, S> {
pub fn builder() -> Self {
StarBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StarBuilder<St, S>
where
St: star_state::State,
St::CreatedAt: star_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> StarBuilder<star_state::SetCreatedAt<St>, S> {
self._fields.0 = Option::Some(value.into());
StarBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StarBuilder<St, S>
where
St: star_state::State,
St::Subject: star_state::IsUnset,
{
pub fn subject(
mut self,
value: impl Into<StarSubject<S>>,
) -> StarBuilder<star_state::SetSubject<St>, S> {
self._fields.1 = Option::Some(value.into());
StarBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StarBuilder<St, S>
where
St: star_state::State,
St::CreatedAt: star_state::IsSet,
St::Subject: star_state::IsSet,
{
pub fn build(self) -> Star<S> {
Star {
created_at: self._fields.0.unwrap(),
subject: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Star<S> {
Star {
created_at: self._fields.0.unwrap(),
subject: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_feed_star() -> 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("sh.tangled.feed.star"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("subject"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#repo"), CowStr::new_static("#string")
],
closed: Some(true),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repo"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("string"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod repo_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;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct RepoBuilder<St: repo_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>,),
_type: PhantomData<fn() -> S>,
}
impl Repo<DefaultStr> {
pub fn new() -> RepoBuilder<repo_state::Empty, DefaultStr> {
RepoBuilder::new()
}
}
impl<S: BosStr> Repo<S> {
pub fn builder() -> RepoBuilder<repo_state::Empty, S> {
RepoBuilder::builder()
}
}
impl RepoBuilder<repo_state::Empty, DefaultStr> {
pub fn new() -> Self {
RepoBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr> RepoBuilder<repo_state::Empty, S> {
pub fn builder() -> Self {
RepoBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> RepoBuilder<St, S>
where
St: repo_state::State,
St::Did: repo_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> RepoBuilder<repo_state::SetDid<St>, S> {
self._fields.0 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> RepoBuilder<St, S>
where
St: repo_state::State,
St::Did: repo_state::IsSet,
{
pub fn build(self) -> Repo<S> {
Repo {
did: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Repo<S> {
Repo {
did: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod star_string_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;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = 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>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct StarStringBuilder<St: star_string_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>,),
_type: PhantomData<fn() -> S>,
}
impl StarString<DefaultStr> {
pub fn new() -> StarStringBuilder<star_string_state::Empty, DefaultStr> {
StarStringBuilder::new()
}
}
impl<S: BosStr> StarString<S> {
pub fn builder() -> StarStringBuilder<star_string_state::Empty, S> {
StarStringBuilder::builder()
}
}
impl StarStringBuilder<star_string_state::Empty, DefaultStr> {
pub fn new() -> Self {
StarStringBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr> StarStringBuilder<star_string_state::Empty, S> {
pub fn builder() -> Self {
StarStringBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StarStringBuilder<St, S>
where
St: star_string_state::State,
St::Uri: star_string_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<AtUri<S>>,
) -> StarStringBuilder<star_string_state::SetUri<St>, S> {
self._fields.0 = Option::Some(value.into());
StarStringBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> StarStringBuilder<St, S>
where
St: star_string_state::State,
St::Uri: star_string_state::IsSet,
{
pub fn build(self) -> StarString<S> {
StarString {
uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> StarString<S> {
StarString {
uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}