#[jacquard_derive::lexicon]
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct Layer<'a> {
pub created_at: jacquard_common::types::string::Datetime,
#[serde(borrow)]
pub digest: jacquard_common::CowStr<'a>,
#[serde(borrow)]
pub manifest: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub media_type: jacquard_common::CowStr<'a>,
pub size: i64,
#[serde(borrow)]
pub user_did: jacquard_common::types::string::Did<'a>,
}
pub mod layer_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 Size;
type MediaType;
type Manifest;
type UserDid;
type Digest;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Size = Unset;
type MediaType = Unset;
type Manifest = Unset;
type UserDid = Unset;
type Digest = Unset;
type CreatedAt = Unset;
}
pub struct SetSize<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSize<S> {}
impl<S: State> State for SetSize<S> {
type Size = Set<members::size>;
type MediaType = S::MediaType;
type Manifest = S::Manifest;
type UserDid = S::UserDid;
type Digest = S::Digest;
type CreatedAt = S::CreatedAt;
}
pub struct SetMediaType<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMediaType<S> {}
impl<S: State> State for SetMediaType<S> {
type Size = S::Size;
type MediaType = Set<members::media_type>;
type Manifest = S::Manifest;
type UserDid = S::UserDid;
type Digest = S::Digest;
type CreatedAt = S::CreatedAt;
}
pub struct SetManifest<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetManifest<S> {}
impl<S: State> State for SetManifest<S> {
type Size = S::Size;
type MediaType = S::MediaType;
type Manifest = Set<members::manifest>;
type UserDid = S::UserDid;
type Digest = S::Digest;
type CreatedAt = S::CreatedAt;
}
pub struct SetUserDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUserDid<S> {}
impl<S: State> State for SetUserDid<S> {
type Size = S::Size;
type MediaType = S::MediaType;
type Manifest = S::Manifest;
type UserDid = Set<members::user_did>;
type Digest = S::Digest;
type CreatedAt = S::CreatedAt;
}
pub struct SetDigest<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDigest<S> {}
impl<S: State> State for SetDigest<S> {
type Size = S::Size;
type MediaType = S::MediaType;
type Manifest = S::Manifest;
type UserDid = S::UserDid;
type Digest = Set<members::digest>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Size = S::Size;
type MediaType = S::MediaType;
type Manifest = S::Manifest;
type UserDid = S::UserDid;
type Digest = S::Digest;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct size(());
pub struct media_type(());
pub struct manifest(());
pub struct user_did(());
pub struct digest(());
pub struct created_at(());
}
}
pub struct LayerBuilder<'a, S: layer_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::string::Datetime>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::AtUri<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<i64>,
::core::option::Option<jacquard_common::types::string::Did<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Layer<'a> {
pub fn new() -> LayerBuilder<'a, layer_state::Empty> {
LayerBuilder::new()
}
}
impl<'a> LayerBuilder<'a, layer_state::Empty> {
pub fn new() -> Self {
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: (None, None, None, None, None, None),
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::CreatedAt: layer_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<jacquard_common::types::string::Datetime>,
) -> LayerBuilder<'a, layer_state::SetCreatedAt<S>> {
self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::Digest: layer_state::IsUnset,
{
pub fn digest(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> LayerBuilder<'a, layer_state::SetDigest<S>> {
self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::Manifest: layer_state::IsUnset,
{
pub fn manifest(
mut self,
value: impl Into<jacquard_common::types::string::AtUri<'a>>,
) -> LayerBuilder<'a, layer_state::SetManifest<S>> {
self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::MediaType: layer_state::IsUnset,
{
pub fn media_type(
mut self,
value: impl Into<jacquard_common::CowStr<'a>>,
) -> LayerBuilder<'a, layer_state::SetMediaType<S>> {
self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::Size: layer_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> LayerBuilder<'a, layer_state::SetSize<S>> {
self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::UserDid: layer_state::IsUnset,
{
pub fn user_did(
mut self,
value: impl Into<jacquard_common::types::string::Did<'a>>,
) -> LayerBuilder<'a, layer_state::SetUserDid<S>> {
self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
LayerBuilder {
_phantom_state: ::core::marker::PhantomData,
__unsafe_private_named: self.__unsafe_private_named,
_phantom: ::core::marker::PhantomData,
}
}
}
impl<'a, S> LayerBuilder<'a, S>
where
S: layer_state::State,
S::Size: layer_state::IsSet,
S::MediaType: layer_state::IsSet,
S::Manifest: layer_state::IsSet,
S::UserDid: layer_state::IsSet,
S::Digest: layer_state::IsSet,
S::CreatedAt: layer_state::IsSet,
{
pub fn build(self) -> Layer<'a> {
Layer {
created_at: self.__unsafe_private_named.0.unwrap(),
digest: self.__unsafe_private_named.1.unwrap(),
manifest: self.__unsafe_private_named.2.unwrap(),
media_type: self.__unsafe_private_named.3.unwrap(),
size: self.__unsafe_private_named.4.unwrap(),
user_did: self.__unsafe_private_named.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Layer<'a> {
Layer {
created_at: self.__unsafe_private_named.0.unwrap(),
digest: self.__unsafe_private_named.1.unwrap(),
manifest: self.__unsafe_private_named.2.unwrap(),
media_type: self.__unsafe_private_named.3.unwrap(),
size: self.__unsafe_private_named.4.unwrap(),
user_did: self.__unsafe_private_named.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> Layer<'a> {
pub fn uri(
uri: impl Into<jacquard_common::CowStr<'a>>,
) -> Result<
jacquard_common::types::uri::RecordUri<'a, LayerRecord>,
jacquard_common::types::uri::UriError,
> {
jacquard_common::types::uri::RecordUri::try_from_uri(
jacquard_common::types::string::AtUri::new_cow(uri.into())?,
)
}
}
#[derive(
serde::Serialize,
serde::Deserialize,
Debug,
Clone,
PartialEq,
Eq,
jacquard_derive::IntoStatic
)]
#[serde(rename_all = "camelCase")]
pub struct LayerGetRecordOutput<'a> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
#[serde(borrow)]
pub uri: jacquard_common::types::string::AtUri<'a>,
#[serde(borrow)]
pub value: Layer<'a>,
}
impl From<LayerGetRecordOutput<'_>> for Layer<'_> {
fn from(output: LayerGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl jacquard_common::types::collection::Collection for Layer<'_> {
const NSID: &'static str = "io.atcr.hold.layer";
type Record = LayerRecord;
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct LayerRecord;
impl jacquard_common::xrpc::XrpcResp for LayerRecord {
const NSID: &'static str = "io.atcr.hold.layer";
const ENCODING: &'static str = "application/json";
type Output<'de> = LayerGetRecordOutput<'de>;
type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
}
impl jacquard_common::types::collection::Collection for LayerRecord {
const NSID: &'static str = "io.atcr.hold.layer";
type Record = LayerRecord;
}
impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Layer<'a> {
fn nsid() -> &'static str {
"io.atcr.hold.layer"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
lexicon_doc_io_atcr_hold_layer()
}
fn validate(
&self,
) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
{
let value = &self.digest;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"digest",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.media_type;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"media_type",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
fn lexicon_doc_io_atcr_hold_layer() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
::jacquard_lexicon::lexicon::LexiconDoc {
lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
id: ::jacquard_common::CowStr::new_static("io.atcr.hold.layer"),
revision: None,
description: None,
defs: {
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
description: Some(
::jacquard_common::CowStr::new_static(
"Represents metadata about a container layer stored in the hold. Stored in the hold's embedded PDS for tracking and analytics.",
),
),
key: Some(::jacquard_common::CowStr::new_static("tid")),
record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("digest"),
::jacquard_common::deps::smol_str::SmolStr::new_static("size"),
::jacquard_common::deps::smol_str::SmolStr::new_static("mediaType"),
::jacquard_common::deps::smol_str::SmolStr::new_static("manifest"),
::jacquard_common::deps::smol_str::SmolStr::new_static("userDid"),
::jacquard_common::deps::smol_str::SmolStr::new_static("createdAt")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"createdAt",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"RFC3339 timestamp of when the layer was uploaded",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"digest",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Layer digest (e.g., sha256:abc123...)",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"manifest",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"AT-URI of the manifest that included this layer (e.g., at://did:plc:xyz/io.atcr.manifest/abc123)",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::AtUri,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"mediaType",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"Media type (e.g., application/vnd.oci.image.layer.v1.tar+gzip)",
),
),
format: None,
default: None,
min_length: None,
max_length: Some(128usize),
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"size",
),
::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
description: None,
default: None,
minimum: None,
maximum: None,
r#enum: None,
r#const: None,
}),
);
map.insert(
::jacquard_common::deps::smol_str::SmolStr::new_static(
"userDid",
),
::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
description: Some(
::jacquard_common::CowStr::new_static(
"DID of user who uploaded this layer",
),
),
format: Some(
::jacquard_lexicon::lexicon::LexStringFormat::Did,
),
default: None,
min_length: None,
max_length: None,
min_graphemes: None,
max_graphemes: None,
r#enum: None,
r#const: None,
known_values: None,
}),
);
map
},
}),
}),
);
map
},
}
}