#[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::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::io_atcr::hold::complete_upload;
#[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 CompleteUpload<S: BosStr = DefaultStr> {
pub digest: S,
pub parts: Vec<complete_upload::PartInfo<S>>,
pub upload_id: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CompleteUploadOutput<S: BosStr = DefaultStr> {
pub digest: S,
pub status: 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, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum CompleteUploadError {
#[serde(rename = "InvalidUploadId")]
InvalidUploadId(Option<SmolStr>),
#[serde(rename = "InvalidDigest")]
InvalidDigest(Option<SmolStr>),
#[serde(rename = "MissingParts")]
MissingParts(Option<SmolStr>),
#[serde(rename = "CompletionFailed")]
CompletionFailed(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for CompleteUploadError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::InvalidUploadId(msg) => {
write!(f, "InvalidUploadId")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::InvalidDigest(msg) => {
write!(f, "InvalidDigest")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::MissingParts(msg) => {
write!(f, "MissingParts")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::CompletionFailed(msg) => {
write!(f, "CompletionFailed")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct PartInfo<S: BosStr = DefaultStr> {
pub etag: S,
pub part_number: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub struct CompleteUploadResponse;
impl jacquard_common::xrpc::XrpcResp for CompleteUploadResponse {
const NSID: &'static str = "io.atcr.hold.completeUpload";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = CompleteUploadOutput<S>;
type Err = CompleteUploadError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for CompleteUpload<S> {
const NSID: &'static str = "io.atcr.hold.completeUpload";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Response = CompleteUploadResponse;
}
pub struct CompleteUploadRequest;
impl jacquard_common::xrpc::XrpcEndpoint for CompleteUploadRequest {
const PATH: &'static str = "/xrpc/io.atcr.hold.completeUpload";
const METHOD: jacquard_common::xrpc::XrpcMethod =
jacquard_common::xrpc::XrpcMethod::Procedure("application/json");
type Request<S: BosStr> = CompleteUpload<S>;
type Response = CompleteUploadResponse;
}
impl<S: BosStr> LexiconSchema for PartInfo<S> {
fn nsid() -> &'static str {
"io.atcr.hold.completeUpload"
}
fn def_name() -> &'static str {
"partInfo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_io_atcr_hold_completeUpload()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.etag;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 256usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("etag"),
max: 256usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.part_number;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("part_number"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
pub mod complete_upload_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 Parts;
type UploadId;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Digest = Unset;
type Parts = Unset;
type UploadId = 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 Parts = St::Parts;
type UploadId = St::UploadId;
}
pub struct SetParts<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetParts<St> {}
impl<St: State> State for SetParts<St> {
type Digest = St::Digest;
type Parts = Set<members::parts>;
type UploadId = St::UploadId;
}
pub struct SetUploadId<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUploadId<St> {}
impl<St: State> State for SetUploadId<St> {
type Digest = St::Digest;
type Parts = St::Parts;
type UploadId = Set<members::upload_id>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct digest(());
pub struct parts(());
pub struct upload_id(());
}
}
pub struct CompleteUploadBuilder<S: BosStr, St: complete_upload_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<Vec<complete_upload::PartInfo<S>>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CompleteUpload<S> {
pub fn new() -> CompleteUploadBuilder<S, complete_upload_state::Empty> {
CompleteUploadBuilder::new()
}
}
impl<S: BosStr> CompleteUploadBuilder<S, complete_upload_state::Empty> {
pub fn new() -> Self {
CompleteUploadBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CompleteUploadBuilder<S, St>
where
St: complete_upload_state::State,
St::Digest: complete_upload_state::IsUnset,
{
pub fn digest(
mut self,
value: impl Into<S>,
) -> CompleteUploadBuilder<S, complete_upload_state::SetDigest<St>> {
self._fields.0 = Option::Some(value.into());
CompleteUploadBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CompleteUploadBuilder<S, St>
where
St: complete_upload_state::State,
St::Parts: complete_upload_state::IsUnset,
{
pub fn parts(
mut self,
value: impl Into<Vec<complete_upload::PartInfo<S>>>,
) -> CompleteUploadBuilder<S, complete_upload_state::SetParts<St>> {
self._fields.1 = Option::Some(value.into());
CompleteUploadBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CompleteUploadBuilder<S, St>
where
St: complete_upload_state::State,
St::UploadId: complete_upload_state::IsUnset,
{
pub fn upload_id(
mut self,
value: impl Into<S>,
) -> CompleteUploadBuilder<S, complete_upload_state::SetUploadId<St>> {
self._fields.2 = Option::Some(value.into());
CompleteUploadBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CompleteUploadBuilder<S, St>
where
St: complete_upload_state::State,
St::Digest: complete_upload_state::IsSet,
St::Parts: complete_upload_state::IsSet,
St::UploadId: complete_upload_state::IsSet,
{
pub fn build(self) -> CompleteUpload<S> {
CompleteUpload {
digest: self._fields.0.unwrap(),
parts: self._fields.1.unwrap(),
upload_id: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CompleteUpload<S> {
CompleteUpload {
digest: self._fields.0.unwrap(),
parts: self._fields.1.unwrap(),
upload_id: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod part_info_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 PartNumber;
type Etag;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type PartNumber = Unset;
type Etag = Unset;
}
pub struct SetPartNumber<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPartNumber<St> {}
impl<St: State> State for SetPartNumber<St> {
type PartNumber = Set<members::part_number>;
type Etag = St::Etag;
}
pub struct SetEtag<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEtag<St> {}
impl<St: State> State for SetEtag<St> {
type PartNumber = St::PartNumber;
type Etag = Set<members::etag>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct part_number(());
pub struct etag(());
}
}
pub struct PartInfoBuilder<S: BosStr, St: part_info_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> PartInfo<S> {
pub fn new() -> PartInfoBuilder<S, part_info_state::Empty> {
PartInfoBuilder::new()
}
}
impl<S: BosStr> PartInfoBuilder<S, part_info_state::Empty> {
pub fn new() -> Self {
PartInfoBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PartInfoBuilder<S, St>
where
St: part_info_state::State,
St::Etag: part_info_state::IsUnset,
{
pub fn etag(mut self, value: impl Into<S>) -> PartInfoBuilder<S, part_info_state::SetEtag<St>> {
self._fields.0 = Option::Some(value.into());
PartInfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PartInfoBuilder<S, St>
where
St: part_info_state::State,
St::PartNumber: part_info_state::IsUnset,
{
pub fn part_number(
mut self,
value: impl Into<i64>,
) -> PartInfoBuilder<S, part_info_state::SetPartNumber<St>> {
self._fields.1 = Option::Some(value.into());
PartInfoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PartInfoBuilder<S, St>
where
St: part_info_state::State,
St::PartNumber: part_info_state::IsSet,
St::Etag: part_info_state::IsSet,
{
pub fn build(self) -> PartInfo<S> {
PartInfo {
etag: self._fields.0.unwrap(),
part_number: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> PartInfo<S> {
PartInfo {
etag: self._fields.0.unwrap(),
part_number: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_io_atcr_hold_completeUpload() -> 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.hold.completeUpload"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcProcedure(LexXrpcProcedure {
input: Some(LexXrpcBody {
encoding: CowStr::new_static("application/json"),
schema: Some(LexXrpcBodySchema::Object(LexObject {
required: Some(vec![
SmolStr::new_static("uploadId"),
SmolStr::new_static("digest"),
SmolStr::new_static("parts"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("digest"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Final blob digest (e.g., sha256:abc123...)",
)),
max_length: Some(128usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("parts"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"List of uploaded parts with their ETags",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#partInfo"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uploadId"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Upload session ID from initiateUpload",
)),
max_length: Some(256usize),
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("partInfo"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"Information about a completed upload part",
)),
required: Some(vec![
SmolStr::new_static("partNumber"),
SmolStr::new_static("etag"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("etag"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"ETag returned when the part was uploaded",
)),
max_length: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("partNumber"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}