#[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::{AtUri, Cid};
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};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "place.stream.media.origin",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Origin<S: BosStr = DefaultStr> {
pub blob: S,
pub mime_type: S,
pub size: i64,
#[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")]
pub struct OriginGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Origin<S>,
}
impl<S: BosStr> Origin<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, OriginRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct OriginRecord;
impl XrpcResp for OriginRecord {
const NSID: &'static str = "place.stream.media.origin";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = OriginGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<OriginGetRecordOutput<S>> for Origin<S> {
fn from(output: OriginGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Origin<S> {
const NSID: &'static str = "place.stream.media.origin";
type Record = OriginRecord;
}
impl Collection for OriginRecord {
const NSID: &'static str = "place.stream.media.origin";
type Record = OriginRecord;
}
impl<S: BosStr> LexiconSchema for Origin<S> {
fn nsid() -> &'static str {
"place.stream.media.origin"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_place_stream_media_origin()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod origin_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 Blob;
type MimeType;
type Size;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blob = Unset;
type MimeType = Unset;
type Size = Unset;
}
pub struct SetBlob<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlob<St> {}
impl<St: State> State for SetBlob<St> {
type Blob = Set<members::blob>;
type MimeType = St::MimeType;
type Size = St::Size;
}
pub struct SetMimeType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMimeType<St> {}
impl<St: State> State for SetMimeType<St> {
type Blob = St::Blob;
type MimeType = Set<members::mime_type>;
type Size = St::Size;
}
pub struct SetSize<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSize<St> {}
impl<St: State> State for SetSize<St> {
type Blob = St::Blob;
type MimeType = St::MimeType;
type Size = Set<members::size>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blob(());
pub struct mime_type(());
pub struct size(());
}
}
pub struct OriginBuilder<St: origin_state::State, S: BosStr = DefaultStr> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl Origin<DefaultStr> {
pub fn new() -> OriginBuilder<origin_state::Empty, DefaultStr> {
OriginBuilder::new()
}
}
impl<S: BosStr> Origin<S> {
pub fn builder() -> OriginBuilder<origin_state::Empty, S> {
OriginBuilder::builder()
}
}
impl OriginBuilder<origin_state::Empty, DefaultStr> {
pub fn new() -> Self {
OriginBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr> OriginBuilder<origin_state::Empty, S> {
pub fn builder() -> Self {
OriginBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<St, S: BosStr> OriginBuilder<St, S>
where
St: origin_state::State,
St::Blob: origin_state::IsUnset,
{
pub fn blob(
mut self,
value: impl Into<S>,
) -> OriginBuilder<origin_state::SetBlob<St>, S> {
self._fields.0 = Option::Some(value.into());
OriginBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> OriginBuilder<St, S>
where
St: origin_state::State,
St::MimeType: origin_state::IsUnset,
{
pub fn mime_type(
mut self,
value: impl Into<S>,
) -> OriginBuilder<origin_state::SetMimeType<St>, S> {
self._fields.1 = Option::Some(value.into());
OriginBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> OriginBuilder<St, S>
where
St: origin_state::State,
St::Size: origin_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> OriginBuilder<origin_state::SetSize<St>, S> {
self._fields.2 = Option::Some(value.into());
OriginBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<St, S: BosStr> OriginBuilder<St, S>
where
St: origin_state::State,
St::Blob: origin_state::IsSet,
St::MimeType: origin_state::IsSet,
St::Size: origin_state::IsSet,
{
pub fn build(self) -> Origin<S> {
Origin {
blob: self._fields.0.unwrap(),
mime_type: self._fields.1.unwrap(),
size: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Origin<S> {
Origin {
blob: self._fields.0.unwrap(),
mime_type: self._fields.1.unwrap(),
size: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_place_stream_media_origin() -> 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("place.stream.media.origin"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"An attestation that a MUXL blob is available for download from the publishing node, retrievable via XRPC (com.atproto.repo.getBlob and similar). Published by the Streamplace node that hosts the blob, not by the user who owns the underlying video. The rkey is conventionally the blob's BDASL CID — atproto lexicon doesn't yet have a literal-rkey syntax so we settle for `key: any` and rely on the convention.",
),
),
key: Some(CowStr::new_static("any")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("blob"), SmolStr::new_static("size"),
SmolStr::new_static("mimeType")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blob"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"BLAKE-3 content hash (BDASL CID) of the blob.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mimeType"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"MIME type of the blob (e.g. video/mp4).",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}