aws_multipart_upload/client/request/
abort.rs

1use super::AbortRequestBuilder;
2use crate::client::{UploadClient, UploadId};
3use crate::error::Result;
4use crate::uri::ObjectUri;
5
6use std::fmt::{self, Debug, Formatter};
7use std::pin::Pin;
8use std::task::{Context, Poll};
9
10/// Sending a request to abort an in-progress upload.
11pub struct SendAbortUpload(pub(crate) Pin<Box<dyn Future<Output = Result<()>>>>);
12
13impl SendAbortUpload {
14    /// Create a new `SendAbortUpload`.
15    pub fn new(client: &UploadClient, req: AbortRequest) -> Self {
16        let cli = client.clone();
17        Self(Box::pin(
18            async move { cli.inner.send_abort_upload(req).await },
19        ))
20    }
21}
22
23impl Future for SendAbortUpload {
24    type Output = Result<()>;
25    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
26        self.0.as_mut().poll(cx)
27    }
28}
29
30impl Debug for SendAbortUpload {
31    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
32        f.debug_tuple("SendAbortUpload")
33            .field(&"Future<Output = Result<()>>")
34            .finish()
35    }
36}
37
38/// Request object for aborting a multipart upload.
39#[derive(Debug, Clone)]
40pub struct AbortRequest {
41    pub(crate) id: UploadId,
42    pub(crate) uri: ObjectUri,
43}
44
45impl AbortRequest {
46    /// Create a new `AbortRequest` from the minimum required.
47    pub fn new(id: UploadId, uri: ObjectUri) -> Self {
48        Self { id, uri }
49    }
50
51    /// Set the required properties on the SDK request builder for the operation.
52    pub fn with_builder(&self, builder: AbortRequestBuilder) -> AbortRequestBuilder {
53        builder
54            .bucket(&*self.uri.bucket)
55            .key(&*self.uri.key)
56            .upload_id(&*self.id)
57    }
58}