aboutsummaryrefslogtreecommitdiff
path: root/src/login/mod.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 15:39:54 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 15:39:54 +0200
commitb95028f89e4db7c3158fab3b71ea56a742daba21 (patch)
tree262a212c7eec8cf26ec70cbb7d12c2264a1e3da2 /src/login/mod.rs
parent8b7eb1ca918d26901b0739526341128067ca1cbc (diff)
downloadaerogramme-b95028f89e4db7c3158fab3b71ea56a742daba21.tar.gz
aerogramme-b95028f89e4db7c3158fab3b71ea56a742daba21.zip
Some refactoring on mailbox structures and views
Diffstat (limited to 'src/login/mod.rs')
-rw-r--r--src/login/mod.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/login/mod.rs b/src/login/mod.rs
index 1d5d634..0605d4e 100644
--- a/src/login/mod.rs
+++ b/src/login/mod.rs
@@ -13,7 +13,6 @@ use rand::prelude::*;
use rusoto_core::HttpClient;
use rusoto_credential::{AwsCredentials, StaticProvider};
use rusoto_s3::S3Client;
-use rusoto_signature::Region;
use crate::cryptoblob::*;
@@ -52,7 +51,7 @@ pub struct PublicCredentials {
}
/// The struct StorageCredentials contains access key to an S3 and K2V bucket
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct StorageCredentials {
pub s3_region: Region,
pub k2v_region: Region,
@@ -87,6 +86,24 @@ pub struct CryptoKeys {
pub public: PublicKey,
}
+/// A custom S3 region, composed of a region name and endpoint.
+/// We use this instead of rusoto_signature::Region so that we can
+/// derive Hash and Eq
+#[derive(Clone, Debug, Hash, PartialEq, Eq)]
+pub struct Region {
+ pub name: String,
+ pub endpoint: String,
+}
+
+impl Region {
+ pub fn as_rusoto_region(&self) -> rusoto_signature::Region {
+ rusoto_signature::Region::Custom {
+ name: self.name.clone(),
+ endpoint: self.endpoint.clone(),
+ }
+ }
+}
+
// ----
impl Credentials {
@@ -111,7 +128,7 @@ impl StorageCredentials {
);
Ok(K2vClient::new(
- self.k2v_region.clone(),
+ self.k2v_region.as_rusoto_region(),
self.bucket.clone(),
aws_creds,
None,
@@ -127,7 +144,7 @@ impl StorageCredentials {
Ok(S3Client::new_with(
HttpClient::new()?,
aws_creds_provider,
- self.s3_region.clone(),
+ self.s3_region.as_rusoto_region(),
))
}
}