rusty_s3/actions/
mod.rs

1//! S3 request building and response parsing support
2
3use std::time::Duration;
4
5use jiff::Timestamp;
6use url::Url;
7
8pub use self::create_bucket::CreateBucket;
9pub use self::delete_bucket::DeleteBucket;
10pub use self::delete_object::DeleteObject;
11#[cfg(feature = "full")]
12pub use self::delete_objects::{DeleteObjects, DeleteObjectsResponse, ObjectIdentifier};
13#[cfg(feature = "full")]
14pub use self::get_bucket_policy::{GetBucketPolicy, GetBucketPolicyResponse};
15pub use self::get_object::GetObject;
16pub use self::head_bucket::HeadBucket;
17pub use self::head_object::HeadObject;
18#[cfg(feature = "full")]
19#[doc(inline)]
20pub use self::list_objects_v2::{ListObjectsV2, ListObjectsV2Response};
21pub use self::multipart_upload::abort::AbortMultipartUpload;
22#[cfg(feature = "full")]
23pub use self::multipart_upload::complete::CompleteMultipartUpload;
24#[cfg(feature = "full")]
25pub use self::multipart_upload::create::{CreateMultipartUpload, CreateMultipartUploadResponse};
26#[cfg(feature = "full")]
27pub use self::multipart_upload::list_parts::{ListParts, ListPartsResponse};
28pub use self::multipart_upload::upload::UploadPart;
29pub use self::put_object::PutObject;
30use crate::{Map, Method};
31
32mod create_bucket;
33mod delete_bucket;
34mod delete_object;
35#[cfg(feature = "full")]
36mod delete_objects;
37#[cfg(feature = "full")]
38mod get_bucket_policy;
39mod get_object;
40mod head_bucket;
41mod head_object;
42#[cfg(feature = "full")]
43pub mod list_objects_v2;
44mod multipart_upload;
45mod put_object;
46
47/// A request which can be signed
48pub trait S3Action<'a> {
49    const METHOD: Method;
50
51    /// Sign a request for this action, using `METHOD` for the [`Method`]
52    fn sign(&self, expires_in: Duration) -> Url {
53        let now = Timestamp::now();
54        self.sign_with_time(expires_in, &now)
55    }
56
57    /// Get a mutable reference to the query string of this action
58    fn query_mut(&mut self) -> &mut Map<'a>;
59
60    /// Get a mutable reference to the signed headers of this action
61    ///
62    /// Headers specified here must also be present in the final request,
63    /// with the same value specified, otherwise the S3 API will return an error.
64    fn headers_mut(&mut self) -> &mut Map<'a>;
65
66    /// Takes the time at which the URL should be signed
67    /// Used for testing purposes
68    fn sign_with_time(&self, expires_in: Duration, time: &Timestamp) -> Url;
69}