#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, Did, UriValue};
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;
use crate::io_atcr::manifest;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct BlobReference<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub annotations: Option<Data<S>>,
pub digest: S,
pub media_type: S,
pub size: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub urls: Option<Vec<UriValue<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",
rename = "io.atcr.manifest",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Manifest<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub annotations: Option<Data<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub config: Option<manifest::BlobReference<S>>,
pub created_at: Datetime,
pub digest: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub hold_did: Option<Did<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub hold_endpoint: Option<UriValue<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub layers: Option<Vec<manifest::BlobReference<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest_blob: Option<BlobRef<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manifests: Option<Vec<manifest::ManifestReference<S>>>,
pub media_type: ManifestMediaType<S>,
pub repository: S,
pub schema_version: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<manifest::BlobReference<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 ManifestMediaType<S: BosStr = DefaultStr> {
ApplicationVndOciImageManifestV1Json,
ApplicationVndDockerDistributionManifestV2Json,
ApplicationVndOciImageIndexV1Json,
ApplicationVndDockerDistributionManifestListV2Json,
Other(S),
}
impl<S: BosStr> ManifestMediaType<S> {
pub fn as_str(&self) -> &str {
match self {
Self::ApplicationVndOciImageManifestV1Json => {
"application/vnd.oci.image.manifest.v1+json"
}
Self::ApplicationVndDockerDistributionManifestV2Json => {
"application/vnd.docker.distribution.manifest.v2+json"
}
Self::ApplicationVndOciImageIndexV1Json => "application/vnd.oci.image.index.v1+json",
Self::ApplicationVndDockerDistributionManifestListV2Json => {
"application/vnd.docker.distribution.manifest.list.v2+json"
}
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"application/vnd.oci.image.manifest.v1+json" => {
Self::ApplicationVndOciImageManifestV1Json
}
"application/vnd.docker.distribution.manifest.v2+json" => {
Self::ApplicationVndDockerDistributionManifestV2Json
}
"application/vnd.oci.image.index.v1+json" => Self::ApplicationVndOciImageIndexV1Json,
"application/vnd.docker.distribution.manifest.list.v2+json" => {
Self::ApplicationVndDockerDistributionManifestListV2Json
}
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for ManifestMediaType<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for ManifestMediaType<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for ManifestMediaType<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 ManifestMediaType<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 ManifestMediaType<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for ManifestMediaType<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = ManifestMediaType<S::Output>;
fn into_static(self) -> Self::Output {
match self {
ManifestMediaType::ApplicationVndOciImageManifestV1Json => {
ManifestMediaType::ApplicationVndOciImageManifestV1Json
}
ManifestMediaType::ApplicationVndDockerDistributionManifestV2Json => {
ManifestMediaType::ApplicationVndDockerDistributionManifestV2Json
}
ManifestMediaType::ApplicationVndOciImageIndexV1Json => {
ManifestMediaType::ApplicationVndOciImageIndexV1Json
}
ManifestMediaType::ApplicationVndDockerDistributionManifestListV2Json => {
ManifestMediaType::ApplicationVndDockerDistributionManifestListV2Json
}
ManifestMediaType::Other(v) => ManifestMediaType::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ManifestGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Manifest<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ManifestReference<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub annotations: Option<Data<S>>,
pub digest: S,
pub media_type: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub platform: Option<manifest::Platform<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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Platform<S: BosStr = DefaultStr> {
pub architecture: S,
pub os: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub os_features: Option<Vec<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub variant: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Manifest<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, ManifestRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for BlobReference<S> {
fn nsid() -> &'static str {
"io.atcr.manifest"
}
fn def_name() -> &'static str {
"blobReference"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_io_atcr_manifest()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.digest;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: 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(ConstraintError::MaxLength {
path: ValidationPath::from_field("media_type"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ManifestRecord;
impl XrpcResp for ManifestRecord {
const NSID: &'static str = "io.atcr.manifest";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ManifestGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<ManifestGetRecordOutput<S>> for Manifest<S> {
fn from(output: ManifestGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Manifest<S> {
const NSID: &'static str = "io.atcr.manifest";
type Record = ManifestRecord;
}
impl Collection for ManifestRecord {
const NSID: &'static str = "io.atcr.manifest";
type Record = ManifestRecord;
}
impl<S: BosStr> LexiconSchema for Manifest<S> {
fn nsid() -> &'static str {
"io.atcr.manifest"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_io_atcr_manifest()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.digest;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: 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(ConstraintError::MaxLength {
path: ValidationPath::from_field("media_type"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.repository;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 255usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("repository"),
max: 255usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ManifestReference<S> {
fn nsid() -> &'static str {
"io.atcr.manifest"
}
fn def_name() -> &'static str {
"manifestReference"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_io_atcr_manifest()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.digest;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 128usize {
return Err(ConstraintError::MaxLength {
path: 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(ConstraintError::MaxLength {
path: ValidationPath::from_field("media_type"),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Platform<S> {
fn nsid() -> &'static str {
"io.atcr.manifest"
}
fn def_name() -> &'static str {
"platform"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_io_atcr_manifest()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.architecture;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("architecture"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.os;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("os"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.os_version {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 64usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("os_version"),
max: 64usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.variant {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 32usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("variant"),
max: 32usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
pub mod blob_reference_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Size;
type Digest;
type MediaType;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Size = Unset;
type Digest = Unset;
type MediaType = Unset;
}
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 Size = Set<members::size>;
type Digest = St::Digest;
type MediaType = St::MediaType;
}
pub struct SetDigest<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDigest<St> {}
impl<St: State> State for SetDigest<St> {
type Size = St::Size;
type Digest = Set<members::digest>;
type MediaType = St::MediaType;
}
pub struct SetMediaType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMediaType<St> {}
impl<St: State> State for SetMediaType<St> {
type Size = St::Size;
type Digest = St::Digest;
type MediaType = Set<members::media_type>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct size(());
pub struct digest(());
pub struct media_type(());
}
}
pub struct BlobReferenceBuilder<S: BosStr, St: blob_reference_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Data<S>>,
Option<S>,
Option<S>,
Option<i64>,
Option<Vec<UriValue<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> BlobReference<S> {
pub fn new() -> BlobReferenceBuilder<S, blob_reference_state::Empty> {
BlobReferenceBuilder::new()
}
}
impl<S: BosStr> BlobReferenceBuilder<S, blob_reference_state::Empty> {
pub fn new() -> Self {
BlobReferenceBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: blob_reference_state::State> BlobReferenceBuilder<S, St> {
pub fn annotations(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_annotations(mut self, value: Option<Data<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> BlobReferenceBuilder<S, St>
where
St: blob_reference_state::State,
St::Digest: blob_reference_state::IsUnset,
{
pub fn digest(
mut self,
value: impl Into<S>,
) -> BlobReferenceBuilder<S, blob_reference_state::SetDigest<St>> {
self._fields.1 = Option::Some(value.into());
BlobReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobReferenceBuilder<S, St>
where
St: blob_reference_state::State,
St::MediaType: blob_reference_state::IsUnset,
{
pub fn media_type(
mut self,
value: impl Into<S>,
) -> BlobReferenceBuilder<S, blob_reference_state::SetMediaType<St>> {
self._fields.2 = Option::Some(value.into());
BlobReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobReferenceBuilder<S, St>
where
St: blob_reference_state::State,
St::Size: blob_reference_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> BlobReferenceBuilder<S, blob_reference_state::SetSize<St>> {
self._fields.3 = Option::Some(value.into());
BlobReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: blob_reference_state::State> BlobReferenceBuilder<S, St> {
pub fn urls(mut self, value: impl Into<Option<Vec<UriValue<S>>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_urls(mut self, value: Option<Vec<UriValue<S>>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> BlobReferenceBuilder<S, St>
where
St: blob_reference_state::State,
St::Size: blob_reference_state::IsSet,
St::Digest: blob_reference_state::IsSet,
St::MediaType: blob_reference_state::IsSet,
{
pub fn build(self) -> BlobReference<S> {
BlobReference {
annotations: self._fields.0,
digest: self._fields.1.unwrap(),
media_type: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
urls: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> BlobReference<S> {
BlobReference {
annotations: self._fields.0,
digest: self._fields.1.unwrap(),
media_type: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
urls: self._fields.4,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_io_atcr_manifest() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("io.atcr.manifest"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blobReference"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Reference to a blob stored in S3 or external storage",
)),
required: Some(vec![
SmolStr::new_static("mediaType"),
SmolStr::new_static("size"),
SmolStr::new_static("digest"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("annotations"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("digest"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Content digest (e.g., 'sha256:...')",
)),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mediaType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("MIME type of the blob")),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("urls"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Optional direct URLs to blob (for BYOS)",
)),
items: LexArrayItem::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A container image manifest following OCI specification, stored in ATProto",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("repository"),
SmolStr::new_static("digest"),
SmolStr::new_static("mediaType"),
SmolStr::new_static("schemaVersion"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("annotations"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("config"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#blobReference"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Record creation timestamp"),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("digest"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Content digest (e.g., 'sha256:abc123...')",
),
),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("holdDid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"DID of the hold service where blobs are stored (e.g., 'did:web:hold01.atcr.io'). Primary reference for hold resolution.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("holdEndpoint"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Hold service endpoint URL where blobs are stored. DEPRECATED: Use holdDid instead. Kept for backward compatibility.",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("layers"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Filesystem layers (for image manifests)",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#blobReference"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("manifestBlob"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("manifests"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Referenced manifests (for manifest lists/indexes)",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#manifestReference"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mediaType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("OCI media type")),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repository"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Repository name (e.g., 'myapp'). Scoped to user's DID.",
),
),
max_length: Some(255usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("schemaVersion"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("subject"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#blobReference"),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("manifestReference"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Reference to a manifest in a manifest list/index",
)),
required: Some(vec![
SmolStr::new_static("mediaType"),
SmolStr::new_static("size"),
SmolStr::new_static("digest"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("annotations"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("digest"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Content digest (e.g., 'sha256:...')",
)),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mediaType"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Media type of the referenced manifest",
)),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("platform"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#platform"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("platform"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Platform information describing OS and architecture",
)),
required: Some(vec![
SmolStr::new_static("architecture"),
SmolStr::new_static("os"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("architecture"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"CPU architecture (e.g., 'amd64', 'arm64', 'arm')",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("os"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Operating system (e.g., 'linux', 'windows', 'darwin')",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("osFeatures"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("Optional OS features")),
items: LexArrayItem::String(LexString {
max_length: Some(64usize),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("osVersion"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Optional OS version")),
max_length: Some(64usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("variant"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Optional CPU variant (e.g., 'v7' for ARM)",
)),
max_length: Some(32usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod manifest_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type CreatedAt;
type MediaType;
type SchemaVersion;
type Digest;
type Repository;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CreatedAt = Unset;
type MediaType = Unset;
type SchemaVersion = Unset;
type Digest = Unset;
type Repository = 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 MediaType = St::MediaType;
type SchemaVersion = St::SchemaVersion;
type Digest = St::Digest;
type Repository = St::Repository;
}
pub struct SetMediaType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMediaType<St> {}
impl<St: State> State for SetMediaType<St> {
type CreatedAt = St::CreatedAt;
type MediaType = Set<members::media_type>;
type SchemaVersion = St::SchemaVersion;
type Digest = St::Digest;
type Repository = St::Repository;
}
pub struct SetSchemaVersion<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSchemaVersion<St> {}
impl<St: State> State for SetSchemaVersion<St> {
type CreatedAt = St::CreatedAt;
type MediaType = St::MediaType;
type SchemaVersion = Set<members::schema_version>;
type Digest = St::Digest;
type Repository = St::Repository;
}
pub struct SetDigest<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDigest<St> {}
impl<St: State> State for SetDigest<St> {
type CreatedAt = St::CreatedAt;
type MediaType = St::MediaType;
type SchemaVersion = St::SchemaVersion;
type Digest = Set<members::digest>;
type Repository = St::Repository;
}
pub struct SetRepository<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepository<St> {}
impl<St: State> State for SetRepository<St> {
type CreatedAt = St::CreatedAt;
type MediaType = St::MediaType;
type SchemaVersion = St::SchemaVersion;
type Digest = St::Digest;
type Repository = Set<members::repository>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct created_at(());
pub struct media_type(());
pub struct schema_version(());
pub struct digest(());
pub struct repository(());
}
}
pub struct ManifestBuilder<S: BosStr, St: manifest_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Data<S>>,
Option<manifest::BlobReference<S>>,
Option<Datetime>,
Option<S>,
Option<Did<S>>,
Option<UriValue<S>>,
Option<Vec<manifest::BlobReference<S>>>,
Option<BlobRef<S>>,
Option<Vec<manifest::ManifestReference<S>>>,
Option<ManifestMediaType<S>>,
Option<S>,
Option<i64>,
Option<manifest::BlobReference<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Manifest<S> {
pub fn new() -> ManifestBuilder<S, manifest_state::Empty> {
ManifestBuilder::new()
}
}
impl<S: BosStr> ManifestBuilder<S, manifest_state::Empty> {
pub fn new() -> Self {
ManifestBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn annotations(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_annotations(mut self, value: Option<Data<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn config(mut self, value: impl Into<Option<manifest::BlobReference<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_config(mut self, value: Option<manifest::BlobReference<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::CreatedAt: manifest_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> ManifestBuilder<S, manifest_state::SetCreatedAt<St>> {
self._fields.2 = Option::Some(value.into());
ManifestBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::Digest: manifest_state::IsUnset,
{
pub fn digest(
mut self,
value: impl Into<S>,
) -> ManifestBuilder<S, manifest_state::SetDigest<St>> {
self._fields.3 = Option::Some(value.into());
ManifestBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn hold_did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_hold_did(mut self, value: Option<Did<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn hold_endpoint(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_hold_endpoint(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn layers(mut self, value: impl Into<Option<Vec<manifest::BlobReference<S>>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_layers(mut self, value: Option<Vec<manifest::BlobReference<S>>>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn manifest_blob(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.7 = value.into();
self
}
pub fn maybe_manifest_blob(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.7 = value;
self
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn manifests(
mut self,
value: impl Into<Option<Vec<manifest::ManifestReference<S>>>>,
) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_manifests(mut self, value: Option<Vec<manifest::ManifestReference<S>>>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::MediaType: manifest_state::IsUnset,
{
pub fn media_type(
mut self,
value: impl Into<ManifestMediaType<S>>,
) -> ManifestBuilder<S, manifest_state::SetMediaType<St>> {
self._fields.9 = Option::Some(value.into());
ManifestBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::Repository: manifest_state::IsUnset,
{
pub fn repository(
mut self,
value: impl Into<S>,
) -> ManifestBuilder<S, manifest_state::SetRepository<St>> {
self._fields.10 = Option::Some(value.into());
ManifestBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::SchemaVersion: manifest_state::IsUnset,
{
pub fn schema_version(
mut self,
value: impl Into<i64>,
) -> ManifestBuilder<S, manifest_state::SetSchemaVersion<St>> {
self._fields.11 = Option::Some(value.into());
ManifestBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: manifest_state::State> ManifestBuilder<S, St> {
pub fn subject(mut self, value: impl Into<Option<manifest::BlobReference<S>>>) -> Self {
self._fields.12 = value.into();
self
}
pub fn maybe_subject(mut self, value: Option<manifest::BlobReference<S>>) -> Self {
self._fields.12 = value;
self
}
}
impl<S: BosStr, St> ManifestBuilder<S, St>
where
St: manifest_state::State,
St::CreatedAt: manifest_state::IsSet,
St::MediaType: manifest_state::IsSet,
St::SchemaVersion: manifest_state::IsSet,
St::Digest: manifest_state::IsSet,
St::Repository: manifest_state::IsSet,
{
pub fn build(self) -> Manifest<S> {
Manifest {
annotations: self._fields.0,
config: self._fields.1,
created_at: self._fields.2.unwrap(),
digest: self._fields.3.unwrap(),
hold_did: self._fields.4,
hold_endpoint: self._fields.5,
layers: self._fields.6,
manifest_blob: self._fields.7,
manifests: self._fields.8,
media_type: self._fields.9.unwrap(),
repository: self._fields.10.unwrap(),
schema_version: self._fields.11.unwrap(),
subject: self._fields.12,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Manifest<S> {
Manifest {
annotations: self._fields.0,
config: self._fields.1,
created_at: self._fields.2.unwrap(),
digest: self._fields.3.unwrap(),
hold_did: self._fields.4,
hold_endpoint: self._fields.5,
layers: self._fields.6,
manifest_blob: self._fields.7,
manifests: self._fields.8,
media_type: self._fields.9.unwrap(),
repository: self._fields.10.unwrap(),
schema_version: self._fields.11.unwrap(),
subject: self._fields.12,
extra_data: Some(extra_data),
}
}
}
pub mod manifest_reference_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Digest;
type MediaType;
type Size;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Digest = Unset;
type MediaType = Unset;
type Size = Unset;
}
pub struct SetDigest<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDigest<St> {}
impl<St: State> State for SetDigest<St> {
type Digest = Set<members::digest>;
type MediaType = St::MediaType;
type Size = St::Size;
}
pub struct SetMediaType<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMediaType<St> {}
impl<St: State> State for SetMediaType<St> {
type Digest = St::Digest;
type MediaType = Set<members::media_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 Digest = St::Digest;
type MediaType = St::MediaType;
type Size = Set<members::size>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct digest(());
pub struct media_type(());
pub struct size(());
}
}
pub struct ManifestReferenceBuilder<S: BosStr, St: manifest_reference_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Data<S>>,
Option<S>,
Option<S>,
Option<manifest::Platform<S>>,
Option<i64>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ManifestReference<S> {
pub fn new() -> ManifestReferenceBuilder<S, manifest_reference_state::Empty> {
ManifestReferenceBuilder::new()
}
}
impl<S: BosStr> ManifestReferenceBuilder<S, manifest_reference_state::Empty> {
pub fn new() -> Self {
ManifestReferenceBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: manifest_reference_state::State> ManifestReferenceBuilder<S, St> {
pub fn annotations(mut self, value: impl Into<Option<Data<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_annotations(mut self, value: Option<Data<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> ManifestReferenceBuilder<S, St>
where
St: manifest_reference_state::State,
St::Digest: manifest_reference_state::IsUnset,
{
pub fn digest(
mut self,
value: impl Into<S>,
) -> ManifestReferenceBuilder<S, manifest_reference_state::SetDigest<St>> {
self._fields.1 = Option::Some(value.into());
ManifestReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ManifestReferenceBuilder<S, St>
where
St: manifest_reference_state::State,
St::MediaType: manifest_reference_state::IsUnset,
{
pub fn media_type(
mut self,
value: impl Into<S>,
) -> ManifestReferenceBuilder<S, manifest_reference_state::SetMediaType<St>> {
self._fields.2 = Option::Some(value.into());
ManifestReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: manifest_reference_state::State> ManifestReferenceBuilder<S, St> {
pub fn platform(mut self, value: impl Into<Option<manifest::Platform<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_platform(mut self, value: Option<manifest::Platform<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> ManifestReferenceBuilder<S, St>
where
St: manifest_reference_state::State,
St::Size: manifest_reference_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> ManifestReferenceBuilder<S, manifest_reference_state::SetSize<St>> {
self._fields.4 = Option::Some(value.into());
ManifestReferenceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ManifestReferenceBuilder<S, St>
where
St: manifest_reference_state::State,
St::Digest: manifest_reference_state::IsSet,
St::MediaType: manifest_reference_state::IsSet,
St::Size: manifest_reference_state::IsSet,
{
pub fn build(self) -> ManifestReference<S> {
ManifestReference {
annotations: self._fields.0,
digest: self._fields.1.unwrap(),
media_type: self._fields.2.unwrap(),
platform: self._fields.3,
size: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ManifestReference<S> {
ManifestReference {
annotations: self._fields.0,
digest: self._fields.1.unwrap(),
media_type: self._fields.2.unwrap(),
platform: self._fields.3,
size: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}