Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overhaul this crate's interface #57

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
[package]
name = "async-session"
version = "3.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/http-rs/async-session"
documentation = "https://docs.rs/async-session"
description = "Async session support with pluggable stores"
readme = "README.md"
edition = "2021"
keywords = []
categories = []
authors = [
"Yoshua Wuyts <[email protected]>",
"Jacob Rothstein <[email protected]>"
]

[dependencies]
async-trait = "0.1.59"
rand = "0.8.5"
base64 = "0.20.0"
sha2 = "0.10.6"
hmac = "0.12.1"
serde_json = "1.0.89"
bincode = "1.3.3"
anyhow = "1.0.66"
blake3 = "1.3.3"
async-lock = "2.6.0"
log = "0.4.17"

[dependencies.serde]
version = "1.0.150"
features = ["rc", "derive"]

[dependencies.time]
version = "0.3.17"
features = ["serde"]

[dev-dependencies.async-std]
version = "1.12.0"
features = ["attributes"]
[workspace]
resolver = "2"
members = ["async-session", "memory-store", "cookie-store"]
37 changes: 37 additions & 0 deletions async-session/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "async-session"
version = "3.0.0"
license = "MIT OR Apache-2.0"
repository = "https://github.com/http-rs/async-session"
documentation = "https://docs.rs/async-session"
description = "Async session support with pluggable stores"
readme = "README.md"
edition = "2021"
keywords = []
categories = []
authors = [
"Yoshua Wuyts <[email protected]>",
"Jacob Rothstein <[email protected]>"
]

[dependencies]
async-trait = "0.1.64"
rand = "0.8.5"
base64 = "0.21.0"
serde_json = "1.0.93"
blake3 = "1.3.3"

[dependencies.serde]
version = "1.0.152"
features = ["derive"]

[dependencies.time]
version = "0.3.18"
features = ["serde"]

[dev-dependencies.async-std]
version = "1.12.0"
features = ["attributes"]

[dev-dependencies]
async-session-memory-store = {path = "../memory-store"}
25 changes: 5 additions & 20 deletions src/lib.rs → async-session/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
//! # Example
//!
//! ```
//! use async_session::{Session, SessionStore, MemoryStore};
//! use async_session::{Session, SessionStore};
//! use async_session_memory_store::MemoryStore;
//!
//! # fn main() -> async_session::Result {
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # async_std::task::block_on(async {
//! #
//! // Init a new session store we can persist sessions to.
Expand All @@ -22,10 +23,10 @@
//! assert!(session.data_changed());
//!
//! // retrieve the cookie value to store in a session cookie
//! let cookie_value = store.store_session(session).await?.unwrap();
//! let cookie_value = store.store_session(&mut session).await?.unwrap();
//!
//! // Retrieve the session using the cookie.
//! let session = store.load_session(cookie_value).await?.unwrap();
//! let session = store.load_session(&cookie_value).await?.unwrap();
//! assert_eq!(session.get::<usize>("user_id").unwrap(), 1);
//! assert!(!session.data_changed());
//! #
Expand All @@ -46,26 +47,10 @@
unused_qualifications
)]

pub use anyhow::Error;
/// An anyhow::Result with default return type of ()
pub type Result<T = ()> = std::result::Result<T, Error>;

mod cookie_store;
mod memory_store;
mod session;
mod session_store;

pub use cookie_store::CookieStore;
pub use memory_store::MemoryStore;
pub use session::Session;
pub use session_store::SessionStore;

pub use async_trait::async_trait;
pub use base64;
pub use blake3;
pub use hmac;
pub use log;
pub use serde;
pub use serde_json;
pub use sha2;
pub use time;
Loading