rusty_cat/presigned/completion_request.rs
1use reqwest::header::HeaderMap;
2use reqwest::Method;
3
4/// One HTTP request used for completion or abort callbacks.
5#[derive(Debug, Clone)]
6pub struct CompletionRequest {
7 /// HTTP method used for the callback.
8 pub method: Method,
9 /// Target URL.
10 pub url: String,
11 /// Request headers.
12 pub headers: HeaderMap,
13 /// Optional request body.
14 pub body: Option<Vec<u8>>,
15 /// When true and `body` is `None`, completion sends a JSON payload with
16 /// `upload_id`, sizes, and uploaded part metadata (`ETag`, provider id).
17 pub uploaded_parts_json_body: bool,
18}
19
20impl CompletionRequest {
21 /// Creates a request without body.
22 pub fn new(method: Method, url: impl Into<String>) -> Self {
23 Self {
24 method,
25 url: url.into(),
26 headers: HeaderMap::new(),
27 body: None,
28 uploaded_parts_json_body: false,
29 }
30 }
31
32 /// Replaces request headers.
33 pub fn with_headers(mut self, headers: HeaderMap) -> Self {
34 self.headers = headers;
35 self
36 }
37
38 /// Sets request body bytes.
39 pub fn with_body(mut self, body: Vec<u8>) -> Self {
40 self.body = Some(body);
41 self
42 }
43
44 /// Uses an auto-generated JSON body containing uploaded part metadata.
45 ///
46 /// This is intended for presigned multipart flows where the application
47 /// server performs final merge after receiving the uploaded `partNumber` +
48 /// `ETag` list from the client.
49 pub fn with_uploaded_parts_json_body(mut self) -> Self {
50 self.uploaded_parts_json_body = true;
51 self
52 }
53}