Skip to content

Commit

Permalink
updates for async-sessions-v4
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Feb 17, 2023
1 parent 06a3abb commit b6cfef9
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 324 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
RUST_TEST_THREADS = "1"
13 changes: 3 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,23 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- name: check avoid-dev-deps
uses: actions-rs/cargo@v1
if: matrix.rust == 'nightly'
with:
command: check
args: --all -Z avoid-dev-deps

- name: pg tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features pg,async_std -- --test-threads=1
args: --all --features pg -- --test-threads=1

- name: sqlite tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features sqlite,async_std
args: --all --features sqlite

- name: mysql tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all --features mysql,async_std -- --test-threads=1
args: --all --features mysql -- --test-threads=1

check_fmt_and_docs:
name: Checking fmt, clippy, and docs
Expand Down
18 changes: 11 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ keywords = ["sessions", "sqlx", "sqlite", "postgres", "mysql"]
categories = ["web-programming::http-server", "web-programming", "database"]

[package.metadata.docs.rs]
features = ["pg", "sqlite", "mysql", "async_std"]
features = ["pg", "sqlite", "mysql"]

[features]
default = ["native-tls"]
default = []
sqlite = ["sqlx/sqlite"]
pg = ["sqlx/postgres", "sqlx/json"]
native-tls = ["sqlx/runtime-async-std-native-tls"]
rustls = ["sqlx/runtime-async-std-rustls"]
async_std = ["async-std"]
mysql = ["sqlx/mysql", "sqlx/json"]

[dependencies]
async-session = "3.0.0"
sqlx = { version = "0.6.2", features = ["chrono"] }
async-std = { version = "1.12.0", optional = true }
async-session = { git = "https://github.com/http-rs/async-session", branch = "overhaul-session-and-session-store", default-features = false }
sqlx = { version = "0.6.2", features = ["time"] }
log = "0.4.17"
serde_json = "1.0.93"
serde = "1.0.152"
thiserror = "1.0.38"
time = "0.3.18"
base64 = "0.21.0"

[dev-dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }

[dev-dependencies.sqlx]
version = "0.6.2"
features = ["chrono", "runtime-async-std-native-tls"]
features = ["runtime-async-std-native-tls"]
17 changes: 17 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// Errors that can arise in the operation of the session stores
/// included in this crate
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
/// an error that comes from sqlx
#[error(transparent)]
SqlxError(#[from] sqlx::Error),

/// an error that comes from serde_json
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),

/// an error that comes from base64
#[error(transparent)]
Base64(#[from] base64::DecodeError),
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ pub use pg::PostgresSessionStore;
mod mysql;
#[cfg(feature = "mysql")]
pub use mysql::MySqlSessionStore;

mod error;
pub use error::Error;
Loading

0 comments on commit b6cfef9

Please sign in to comment.