diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-18 14:54:48 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-18 14:54:48 +0200 |
commit | c8be884ad5230b531dfb54ee978e19d4eafe29a2 (patch) | |
tree | 8650943282946c051b48b91cd450d0d010a7dc1d /src/main.rs | |
parent | cfc02ba3685c481ebb71ffeddc970998af987de9 (diff) | |
download | aerogramme-c8be884ad5230b531dfb54ee978e19d4eafe29a2.tar.gz aerogramme-c8be884ad5230b531dfb54ee978e19d4eafe29a2.zip |
sync() and push() seems to be working, todo checkpoint()
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/src/main.rs b/src/main.rs index 81cf220..461cb11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,14 @@ -use anyhow::Result; - -use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; -use rusoto_signature::Region; - mod bayou; mod cryptoblob; mod time; mod uidindex; +use anyhow::Result; + +use rand::prelude::*; +use rusoto_credential::{EnvironmentProvider, ProvideAwsCredentials}; +use rusoto_signature::Region; + use bayou::*; use cryptoblob::Key; use uidindex::*; @@ -32,21 +33,48 @@ async fn do_stuff() -> Result<()> { let key = Key::from_slice(&[0u8; 32]).unwrap(); - let mut mail_index = Bayou::<UidIndex>::new( + let mut uid_index = Bayou::<UidIndex>::new( creds, k2v_region, s3_region, - "alex".into(), + "mail".into(), "TestMailbox".into(), key, )?; - mail_index.sync().await?; + uid_index.sync().await?; + + dump(&uid_index); - let add_mail_op = mail_index + let mut rand_id = [0u8; 24]; + rand_id[..8].copy_from_slice(&u64::to_be_bytes(thread_rng().gen())); + let add_mail_op = uid_index .state() - .op_mail_add(MailUuid([0xFFu8; 24]), vec!["\\Unseen".into()]); - mail_index.push(add_mail_op).await?; + .op_mail_add(MailUuid(rand_id), vec!["\\Unseen".into()]); + uid_index.push(add_mail_op).await?; + + dump(&uid_index); Ok(()) } + +fn dump(uid_index: &Bayou<UidIndex>) { + let s = uid_index.state(); + println!("---- MAILBOX STATE ----"); + println!("UIDVALIDITY {}", s.uidvalidity); + println!("UIDNEXT {}", s.uidnext); + println!("INTERNALSEQ {}", s.internalseq); + for (uid, uuid) in s.mails_by_uid.iter() { + println!( + "{} {} {}", + uid, + hex::encode(uuid.0), + s.mail_flags + .get(uuid) + .cloned() + .unwrap_or_default() + .join(", ") + ); + } + println!(""); +} |