From 08b74238c61a4d41cb252c65dcea3e37329a4914 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 21 Feb 2021 07:57:28 -0600 Subject: [PATCH] fuck strings for now --- Cargo.lock | 5 --- Cargo.toml | 2 +- imap/Cargo.toml | 13 +++--- imap/src/client/inner.rs | 5 +-- imap/src/client/mod.rs | 5 ++- strings/Cargo.toml | 7 ---- strings/src/lib.rs | 87 ---------------------------------------- 7 files changed, 12 insertions(+), 112 deletions(-) delete mode 100644 strings/Cargo.toml delete mode 100644 strings/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 675b0ea..9318a1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -780,7 +780,6 @@ dependencies = [ "futures", "nom 6.1.2", "owning_ref", - "panorama-strings", "parking_lot", "tokio", "tokio-rustls", @@ -788,10 +787,6 @@ dependencies = [ "webpki-roots", ] -[[package]] -name = "panorama-strings" -version = "0.1.0" - [[package]] name = "parking_lot" version = "0.11.1" diff --git a/Cargo.toml b/Cargo.toml index 90d077b..49216b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ readme = "README.md" license = "GPL-3.0-or-later" [workspace] -members = ["imap", "strings"] +members = ["imap"] [dependencies] anyhow = "1.0.38" diff --git a/imap/Cargo.toml b/imap/Cargo.toml index 105f2fc..da6bae4 100644 --- a/imap/Cargo.toml +++ b/imap/Cargo.toml @@ -13,16 +13,15 @@ maintenance = { status = "passively-maintained" } [dependencies] anyhow = "1.0.38" -tokio = { version = "1.1.1", features = ["full"] } +derive_builder = "0.9.0" futures = "0.3.12" nom = { version = "6.1.2", default-features = false, features = ["std"] } -derive_builder = "0.9.0" -tokio-rustls = "0.22.0" -webpki-roots = "0.21.0" -panorama-strings = { path = "../strings", version = "0" } -parking_lot = "0.11.1" -tracing = "0.1.23" owning_ref = "0.4.1" +parking_lot = "0.11.1" +tokio = { version = "1.1.1", features = ["full"] } +tokio-rustls = "0.22.0" +tracing = "0.1.23" +webpki-roots = "0.21.0" [dev-dependencies] assert_matches = "1.3" diff --git a/imap/src/client/inner.rs b/imap/src/client/inner.rs index 3dbe8f5..30649e6 100644 --- a/imap/src/client/inner.rs +++ b/imap/src/client/inner.rs @@ -5,7 +5,6 @@ use std::task::{Context, Poll, Waker}; use anyhow::{Context as AnyhowContext, Result}; use futures::future::{self, Either, Future, FutureExt}; -use panorama_strings::{StringEntry, StringStore}; use parking_lot::{Mutex, RwLock}; use tokio::{ io::{ @@ -33,13 +32,12 @@ pub const TAG_PREFIX: &str = "panorama"; pub struct Client { config: ClientConfig, conn: WriteHalf, - symbols: StringStore, id: usize, results: ResultMap, /// cached set of capabilities - caps: Vec, + caps: Vec, /// join handle for the listener thread listener_handle: JoinHandle>>, @@ -71,7 +69,6 @@ where Client { config, conn: write_half, - symbols: StringStore::new(256), id: 0, results, caps: Vec::new(), diff --git a/imap/src/client/mod.rs b/imap/src/client/mod.rs index 2809f4d..1931306 100644 --- a/imap/src/client/mod.rs +++ b/imap/src/client/mod.rs @@ -8,7 +8,10 @@ //! Because there's many client types for the different types of clients, you'll want to start //! here: //! -//! - [ClientBuilder][self::ClientBuilder] : Constructs the config for the IMAP client +//! - [`ClientBuilder`][self::ClientBuilder] : Constructs the config for the IMAP client +//! +//! If you choose not to use the high-level type-safe features of `ClientBuilder`, then you can +//! also choose to access the lower level [`Client`][self::inner::Client] directly. mod inner; diff --git a/strings/Cargo.toml b/strings/Cargo.toml deleted file mode 100644 index 7f47599..0000000 --- a/strings/Cargo.toml +++ /dev/null @@ -1,7 +0,0 @@ -[package] -name = "panorama-strings" -version = "0.1.0" -authors = ["Michael Zhang "] -edition = "2018" - -[dependencies] diff --git a/strings/src/lib.rs b/strings/src/lib.rs deleted file mode 100644 index 856f211..0000000 --- a/strings/src/lib.rs +++ /dev/null @@ -1,87 +0,0 @@ -use std::collections::HashMap; -use std::hash::Hash; -use std::marker::PhantomData; -use std::ops::Deref; - -pub type StringStore = Store<&'static str>; -pub type StringEntry = Entry<&'static str>; - -pub struct Store { - capacity: usize, - store: Vec>, - index: HashMap, - head: usize, - tail: usize, -} - -impl Store { - pub fn new(capacity: usize) -> Self { - Store { - capacity, - store: Vec::with_capacity(capacity), - index: HashMap::new(), - head: 0, - tail: 0, - } - } - - pub fn insert(&mut self, val: T) { - if self.index.contains_key(&val) { - return; - } - - let entry = Entry { - val, - prev: 0, - next: 0, - }; - - let new_head = if self.store.len() == self.store.capacity() { - let idx = self.pop_back(); - self.store[idx] = entry; - idx - } else { - self.store.push(entry); - self.store.len() - 1 - }; - - self.push_front(new_head); - } - - fn pop_back(&mut self) -> usize { - let old_tail = self.tail; - let new_tail = self.store[old_tail].prev; - self.tail = new_tail; - old_tail - } - - fn push_front(&mut self, idx: usize) { - if self.store.len() == 1 { - self.tail = idx; - } else { - self.store[self.head].prev = idx; - self.store[idx].next = idx; - } - self.head = idx; - } -} - -#[derive(Copy, Clone)] -pub struct Entry { - val: T, - prev: usize, - next: usize, -} - -impl Deref for Entry { - type Target = T; - fn deref(&self) -> &Self::Target { - &self.val - } -} - -impl AsRef for Entry { - fn as_ref(&self) -> &T { - &self.val - } -}