fuck strings for now

This commit is contained in:
Michael Zhang 2021-02-21 07:57:28 -06:00
parent 0b88df1367
commit 08b74238c6
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
7 changed files with 12 additions and 112 deletions

5
Cargo.lock generated
View file

@ -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"

View file

@ -9,7 +9,7 @@ readme = "README.md"
license = "GPL-3.0-or-later"
[workspace]
members = ["imap", "strings"]
members = ["imap"]
[dependencies]
anyhow = "1.0.38"

View file

@ -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"

View file

@ -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<C> {
config: ClientConfig,
conn: WriteHalf<C>,
symbols: StringStore,
id: usize,
results: ResultMap,
/// cached set of capabilities
caps: Vec<StringEntry>,
caps: Vec<String>,
/// join handle for the listener thread
listener_handle: JoinHandle<Result<ReadHalf<C>>>,
@ -71,7 +69,6 @@ where
Client {
config,
conn: write_half,
symbols: StringStore::new(256),
id: 0,
results,
caps: Vec::new(),

View file

@ -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;

View file

@ -1,7 +0,0 @@
[package]
name = "panorama-strings"
version = "0.1.0"
authors = ["Michael Zhang <mail@mzhang.io>"]
edition = "2018"
[dependencies]

View file

@ -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<T> {
capacity: usize,
store: Vec<Entry<T>>,
index: HashMap<T, usize>,
head: usize,
tail: usize,
}
impl<T: Hash + Eq> Store<T> {
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<T> {
val: T,
prev: usize,
next: usize,
}
impl<T: Copy + Clone> Deref for Entry<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.val
}
}
impl<T> AsRef<T> for Entry<T> {
fn as_ref(&self) -> &T {
&self.val
}
}