Skip to content

Commit 35cb099

Browse files
committed
split cookie store and memory store into workspace crates
1 parent c862bde commit 35cb099

File tree

10 files changed

+77
-55
lines changed

10 files changed

+77
-55
lines changed

Cargo.toml

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,3 @@
1-
[package]
2-
name = "async-session"
3-
version = "3.0.0"
4-
license = "MIT OR Apache-2.0"
5-
repository = "https://github.com/http-rs/async-session"
6-
documentation = "https://docs.rs/async-session"
7-
description = "Async session support with pluggable stores"
8-
readme = "README.md"
9-
edition = "2021"
10-
keywords = []
11-
categories = []
12-
authors = [
13-
"Yoshua Wuyts <yoshuawuyts@gmail.com>",
14-
"Jacob Rothstein <hi@jbr.me>"
15-
]
16-
17-
[features]
18-
default = ["memory-store", "cookie-store"]
19-
memory-store = ["dashmap", "thiserror", "log"]
20-
cookie-store = ["bincode-json", "thiserror"]
21-
22-
[dependencies]
23-
async-trait = "0.1.64"
24-
rand = "0.8.5"
25-
base64 = "0.21.0"
26-
serde_json = "1.0.93"
27-
blake3 = "1.3.3"
28-
log = { version = "0.4.17", optional = true }
29-
dashmap = { version = "5.4.0", optional = true }
30-
bincode-json = { version = "0.1.5", features = ["json"], optional = true }
31-
thiserror = { version = "1.0.38", optional = true }
32-
33-
[dependencies.serde]
34-
version = "1.0.152"
35-
features = ["derive"]
36-
37-
[dependencies.time]
38-
version = "0.3.18"
39-
features = ["serde"]
40-
41-
[dev-dependencies.async-std]
42-
version = "1.12.0"
43-
features = ["attributes"]
1+
[workspace]
2+
resolver = "2"
3+
members = ["async-session", "memory-store", "cookie-store"]

async-session/Cargo.toml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[package]
2+
name = "async-session"
3+
version = "3.0.0"
4+
license = "MIT OR Apache-2.0"
5+
repository = "https://github.com/http-rs/async-session"
6+
documentation = "https://docs.rs/async-session"
7+
description = "Async session support with pluggable stores"
8+
readme = "README.md"
9+
edition = "2021"
10+
keywords = []
11+
categories = []
12+
authors = [
13+
"Yoshua Wuyts <yoshuawuyts@gmail.com>",
14+
"Jacob Rothstein <hi@jbr.me>"
15+
]
16+
17+
[dependencies]
18+
async-trait = "0.1.64"
19+
rand = "0.8.5"
20+
base64 = "0.21.0"
21+
serde_json = "1.0.93"
22+
blake3 = "1.3.3"
23+
24+
[dependencies.serde]
25+
version = "1.0.152"
26+
features = ["derive"]
27+
28+
[dependencies.time]
29+
version = "0.3.18"
30+
features = ["serde"]
31+
32+
[dev-dependencies.async-std]
33+
version = "1.12.0"
34+
features = ["attributes"]
35+
36+
[dev-dependencies]
37+
async-session-memory-store = {path = "../memory-store"}

src/lib.rs renamed to async-session/src/lib.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
//! # Example
99
//!
1010
//! ```
11-
//! use async_session::{Session, SessionStore, MemoryStore};
11+
//! use async_session::{Session, SessionStore};
12+
//! use async_session_memory_store::MemoryStore;
1213
//!
1314
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
1415
//! # async_std::task::block_on(async {
@@ -46,17 +47,9 @@
4647
unused_qualifications
4748
)]
4849

49-
#[cfg(feature = "cookie-store")]
50-
mod cookie_store;
51-
#[cfg(feature = "memory-store")]
52-
mod memory_store;
5350
mod session;
5451
mod session_store;
5552

56-
#[cfg(feature = "cookie-store")]
57-
pub use cookie_store::{CookieStore, CookieStoreError};
58-
#[cfg(feature = "memory-store")]
59-
pub use memory_store::{MemoryStore, MemoryStoreError};
6053
pub use session::Session;
6154
pub use session_store::SessionStore;
6255

File renamed without changes.
File renamed without changes.
File renamed without changes.

cookie-store/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "async-session-cookie-store"
3+
version = "0.0.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
async-session = { path = "../async-session", version = "3.0.0" }
8+
base64 = "0.21.0"
9+
bincode-json = { version = "0.1.5", features = ["json"] }
10+
serde_json = "1.0.95"
11+
thiserror = "1.0.38"
12+
13+
[dev-dependencies]
14+
async-std = { version = "1.12.0", features = ["attributes"] }

src/cookie_store.rs renamed to cookie-store/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{async_trait, Session, SessionStore};
1+
use async_session::{async_trait, Session, SessionStore};
22
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
33

44
/// A session store that serializes the entire session into a Cookie.

memory-store/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "async-session-memory-store"
3+
version = "0.0.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
async-session = { path = "../async-session", version = "3.0.0" }
10+
log = "0.4.17"
11+
dashmap = "5.4.0"
12+
thiserror = "1.0.40"
13+
base64 = "0.21.0"
14+
serde_json = "1.0.95"
15+
16+
[dev-dependencies]
17+
async-std = { version = "1.12.0", features = ["attributes"] }

src/memory_store.rs renamed to memory-store/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{async_trait, Session, SessionStore};
1+
use async_session::{async_trait, Session, SessionStore};
22
use dashmap::{mapref::entry::Entry::Occupied, DashMap};
33
use std::sync::Arc;
44

@@ -92,7 +92,8 @@ impl MemoryStore {
9292
/// returns the number of elements in the memory store
9393
/// # Example
9494
/// ```rust
95-
/// # use async_session::{MemoryStore, Session, SessionStore};
95+
/// # use async_session::{Session, SessionStore};
96+
/// # use async_session_memory_store::MemoryStore;
9697
/// # fn main() -> Result<(), Box<dyn std::error::Error>> { async_std::task::block_on(async {
9798
/// let mut store = MemoryStore::new();
9899
/// assert_eq!(store.count(), 0);

0 commit comments

Comments
 (0)