objectstore_service/multipart.rs
1//! Shared types for Objectstore's multipart upload protocol.
2
3use std::time::SystemTime;
4
5/// Identifier for an in-progress multipart upload.
6pub type UploadId = String;
7/// 1-indexed position of a part within its multipart upload.
8pub type PartNumber = u32;
9/// Opaque per-part identifier returned by the backend after a successful part upload.
10pub type ETag = String;
11
12/// Description of one part in the response to
13/// [`MultipartUploadBackend::list_parts`](crate::backend::common::MultipartUploadBackend::list_parts).
14#[derive(Clone, Debug)]
15pub struct Part {
16 /// 1-indexed position of this part within the upload.
17 pub part_number: PartNumber,
18 /// Identifier returned when the part was uploaded.
19 pub etag: ETag,
20 /// Server-recorded time at which the part was uploaded.
21 pub last_modified: SystemTime,
22 /// Size of the part in bytes.
23 pub size: u64,
24}
25
26/// Pair of (part number, ETag) that the client provides on
27/// [`MultipartUploadBackend::complete_multipart`](crate::backend::common::MultipartUploadBackend::complete_multipart)
28/// to identify the parts in order.
29#[derive(Clone, Debug)]
30pub struct CompletedPart {
31 /// 1-indexed position of this part within the upload.
32 pub part_number: PartNumber,
33 /// Identifier returned when the part was uploaded.
34 pub etag: ETag,
35}
36
37/// Error optionally returned by
38/// [`MultipartUploadBackend::complete_multipart`](crate::backend::common::MultipartUploadBackend::complete_multipart).
39#[derive(Clone, Debug)]
40pub struct CompleteMultipartError {
41 /// Error code or identifier.
42 pub code: String,
43 /// Human-readable error description.
44 pub message: String,
45}
46
47/// Response for
48/// [`MultipartUploadBackend::initiate_multipart`](crate::backend::common::MultipartUploadBackend::initiate_multipart).
49pub type InitiateMultipartResponse = UploadId;
50
51/// Response for
52/// [`MultipartUploadBackend::upload_part`](crate::backend::common::MultipartUploadBackend::upload_part).
53pub type UploadPartResponse = ETag;
54
55/// Response for
56/// [`MultipartUploadBackend::list_parts`](crate::backend::common::MultipartUploadBackend::list_parts).
57#[derive(Clone, Debug)]
58pub struct ListPartsResponse {
59 /// Parts uploaded so far, in `part_number` order.
60 pub parts: Vec<Part>,
61 /// Set when the listing was truncated and more parts can be fetched
62 /// using [`Self::next_part_number_marker`] as the next
63 /// `part_number_marker`.
64 pub is_truncated: bool,
65 /// Marker to pass as the next `part_number_marker` when
66 /// [`Self::is_truncated`] is `true`.
67 pub next_part_number_marker: Option<PartNumber>,
68}
69
70/// Response for
71/// [`MultipartUploadBackend::abort_multipart`](crate::backend::common::MultipartUploadBackend::abort_multipart).
72pub type AbortMultipartResponse = ();
73
74/// Response for
75/// [`MultipartUploadBackend::complete_multipart`](crate::backend::common::MultipartUploadBackend::complete_multipart).
76pub type CompleteMultipartResponse = Option<CompleteMultipartError>;