diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-19 12:14:06 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-19 12:14:06 +0200 |
commit | 4bc3f70e287379991eb6e31a2a075752e85958b7 (patch) | |
tree | 2dda8223f3d22c6041ef014e2729ebfc9512c6f8 /src | |
parent | c7f767b7d2877cdbbc06893c9cd0fae2c56b96f2 (diff) | |
download | aerogramme-4bc3f70e287379991eb6e31a2a075752e85958b7.tar.gz aerogramme-4bc3f70e287379991eb6e31a2a075752e85958b7.zip |
cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/login/ldap_provider.rs | 4 | ||||
-rw-r--r-- | src/mailbox.rs | 37 | ||||
-rw-r--r-- | src/main.rs | 18 |
3 files changed, 29 insertions, 30 deletions
diff --git a/src/login/ldap_provider.rs b/src/login/ldap_provider.rs index ebe2771..6108e6e 100644 --- a/src/login/ldap_provider.rs +++ b/src/login/ldap_provider.rs @@ -9,14 +9,14 @@ pub struct LdapLoginProvider { } impl LdapLoginProvider { - pub fn new(config: LoginLdapConfig) -> Result<Self> { + pub fn new(_config: LoginLdapConfig) -> Result<Self> { unimplemented!() } } #[async_trait] impl LoginProvider for LdapLoginProvider { - async fn login(&self, username: &str, password: &str) -> Result<Credentials> { + async fn login(&self, _username: &str, _password: &str) -> Result<Credentials> { unimplemented!() } } diff --git a/src/mailbox.rs b/src/mailbox.rs index 7dcb92a..8e50b80 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -1,15 +1,13 @@ -use anyhow::{anyhow, bail, Result}; -use k2v_client::{BatchDeleteOp, BatchReadOp, Filter, K2vClient, K2vValue}; +use anyhow::Result; +use k2v_client::K2vClient; +use rand::prelude::*; use rusoto_core::HttpClient; -use rusoto_credential::{AwsCredentials, StaticProvider, ProvideAwsCredentials}; -use rusoto_s3::{ - DeleteObjectRequest, GetObjectRequest, ListObjectsV2Request, PutObjectRequest, S3Client, S3, -}; +use rusoto_credential::{ProvideAwsCredentials, StaticProvider}; +use rusoto_s3::S3Client; use rusoto_signature::Region; -use rand::prelude::*; -use crate::cryptoblob::Key; use crate::bayou::Bayou; +use crate::cryptoblob::Key; use crate::login::Credentials; use crate::uidindex::*; @@ -25,11 +23,14 @@ pub struct Mailbox { } impl Mailbox { - pub async fn new(k2v_region: Region, s3_region: Region, creds: Credentials,name: String) -> Result<Self> { - let aws_creds_provider = StaticProvider::new_minimal( - creds.aws_access_key_id, - creds.aws_secret_access_key, - ); + pub async fn new( + k2v_region: Region, + s3_region: Region, + creds: Credentials, + name: String, + ) -> Result<Self> { + let aws_creds_provider = + StaticProvider::new_minimal(creds.aws_access_key_id, creds.aws_secret_access_key); let aws_creds = aws_creds_provider.credentials().await?; let uid_index = Bayou::<UidIndex>::new( @@ -40,7 +41,7 @@ impl Mailbox { name.clone(), creds.master_key.clone(), )?; - + let k2v_client = K2vClient::new(k2v_region, creds.bucket.clone(), aws_creds, None)?; let s3_client = S3Client::new_with(HttpClient::new()?, aws_creds_provider, s3_region); @@ -54,16 +55,15 @@ impl Mailbox { }) } - pub async fn test(&mut self) -> Result<()> { - self.uid_index.sync().await?; dump(&self.uid_index); let mut rand_id = [0u8; 24]; rand_id[..16].copy_from_slice(&u128::to_be_bytes(thread_rng().gen())); - let add_mail_op = self.uid_index + let add_mail_op = self + .uid_index .state() .op_mail_add(MailUuid(rand_id), vec!["\\Unseen".into()]); self.uid_index.push(add_mail_op).await?; @@ -72,7 +72,8 @@ impl Mailbox { if self.uid_index.state().mails_by_uid.len() > 6 { for i in 0..2 { - let (_, uuid) = self.uid_index + let (_, uuid) = self + .uid_index .state() .mails_by_uid .iter() diff --git a/src/main.rs b/src/main.rs index cf1e886..16eafc4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,22 +2,17 @@ mod bayou; mod config; mod cryptoblob; mod login; +mod mailbox; mod time; mod uidindex; -mod mailbox; use anyhow::{bail, Result}; use std::sync::Arc; -use rand::prelude::*; -use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; use rusoto_signature::Region; -use bayou::*; use config::*; -use cryptoblob::Key; use login::{ldap_provider::*, static_provider::*, *}; -use uidindex::*; use mailbox::Mailbox; #[tokio::main] @@ -68,10 +63,13 @@ impl Main { async fn run(self: &Arc<Self>) -> Result<()> { let creds = self.login_provider.login("lx", "plop").await?; - let mut mailbox = Mailbox::new(self.k2v_region.clone(), - self.s3_region.clone(), - creds.clone(), - "TestMailbox".to_string()).await?; + let mut mailbox = Mailbox::new( + self.k2v_region.clone(), + self.s3_region.clone(), + creds.clone(), + "TestMailbox".to_string(), + ) + .await?; mailbox.test().await?; |