Skip to content

Commit bd3afb3

Browse files
authored
Merge pull request #13 from jimmielovell/fix-version
Migrate to native async traits with the following changes
2 parents 502ae67 + 3d38272 commit bd3afb3

File tree

9 files changed

+115
-76
lines changed

9 files changed

+115
-76
lines changed

.DS_Store

0 Bytes
Binary file not shown.

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Changelog
22

3+
## [0.5.0] - 2024-01-11
4+
5+
### Breaking Changes
6+
- Migrated to native async traits with the following changes:
7+
- Removed `#[async_trait]` attribute from `FromRequestParts` implementation to support Axum 0.8+ compatibility
8+
- Refactored `SessionStore` trait to use explicit `Future` returns instead of `async fn`
9+
- If you're using Axum < 0.8, please continue using ruts version 0.4.3
10+
11+
### Added
12+
- Support for Axum 0.8+
13+
14+
### Dependencies
15+
- Updated minimum supported Axum version to 0.8.0
16+
17+
### Migration Guide
18+
If you're upgrading to Axum 0.8+ and using ruts:
19+
1. Update your Axum dependency to 0.8.0 or higher
20+
2. Update ruts to the latest version
21+
3. No additional code changes are required for session handling
22+
23+
The session middleware and extractors will continue to work as before:
24+
```rust
25+
// Your code will continue to work unchanged
26+
async fn handler(
27+
session: Session<RedisStore<Pool>>,
28+
// ... other parameters
29+
) -> Result<(), Error> {
30+
// ... your code
31+
}
32+
```
33+
334
## [0.4.2] - 2024-12-14
435
### Fixed
536
- Match Cargo.toml version and install version in the README.md

Cargo.lock

+37-46
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[package]
22
name = "ruts"
33
description = "A middleware for tower sessions"
4-
version = "0.4.2"
4+
version = "0.5.0"
55
edition = "2021"
6+
rust-version = "1.75.0"
67
authors = ["Jimmie Lovell <[email protected]>"]
78
license = "MIT"
89
homepage = "https://github.com/jimmielovell/ruts"
@@ -18,25 +19,24 @@ axum = ["dep:axum-core"]
1819
redis-store = ["dep:fred", "dep:rmp-serde"]
1920

2021
[dependencies]
21-
async-trait = "0.1.83"
22-
axum-core = { version = "0.4.5", optional = true }
22+
axum-core = { version = "0.5.0", optional = true }
2323
base64 = "0.22.1"
2424
cookie = "0.18.1"
2525
fred = { version = "10.0.1", optional = true }
26-
http = "1.1.0"
26+
http = "1.2.0"
2727
parking_lot = { version = "0.12.3", features = ["serde"] }
2828
pin-project-lite = "0.2.14"
2929
rand = "0.8.5"
3030
rmp-serde = { version = "1.3.0", optional = true }
31-
serde = { version = "1.0.210", features = ["derive"] }
32-
thiserror = "2.0.6"
33-
tokio = { version = "1.40.0", features = ["full"] }
34-
tower = "0.5.1"
35-
tower-cookies = "0.10.0"
36-
tracing = { version = "0.1.40", features = ["log"] }
31+
serde = { version = "1.0.217", features = ["derive"] }
32+
thiserror = "2.0.11"
33+
tokio = { version = "1.43.0", features = ["full"] }
34+
tower = "0.5.2"
35+
tower-cookies = "0.11.0"
36+
tracing = { version = "0.1.41", features = ["log"] }
3737

3838
[dev-dependencies]
39-
axum = "0.7.7"
39+
axum = "0.8.1"
4040
http-body-util = "0.1.2"
4141
hyper = "1.5.1"
4242

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Ruts: Rust Tower Session for HTTP Applications
22

3+
[![Documentation](https://docs.rs/ruts/badge.svg)](https://docs.rs/ruts)
4+
[![Crates.io](https://img.shields.io/crates/v/ruts.svg)](https://crates.io/crates/ruts)
5+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6+
[![Rust](https://img.shields.io/badge/rust-1.75.0%2B-blue.svg?maxAge=3600)](
7+
github.com/jimmielovell/ruts)
8+
39
Ruts is a robust, flexible session management library for Rust web applications. It provides a seamless way to handle cookie sessions in tower-based web frameworks, with a focus on security, performance, and ease of use.
410

511
## Features

src/extract/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::sync::Arc;
22

3-
use async_trait::async_trait;
43
use axum_core::extract::FromRequestParts;
54
use http::{request::Parts, StatusCode};
65
use tower_cookies::Cookies;
@@ -10,7 +9,6 @@ use crate::store::SessionStore;
109
use crate::{Id, Session};
1110

1211
/// axum extractor for [`Session`].
13-
#[async_trait]
1412
impl<S, T> FromRequestParts<S> for Session<T>
1513
where
1614
S: Sync + Send,

src/store/memory.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::collections::HashMap;
22
use std::sync::Arc;
33
use std::time::{Duration, Instant};
44
use parking_lot::RwLock;
5-
use async_trait::async_trait;
65
use serde::{de::DeserializeOwned, Serialize};
76

87
use crate::store::{Error, SessionStore};
@@ -53,7 +52,6 @@ impl MemoryStore {
5352
}
5453
}
5554

56-
#[async_trait]
5755
impl SessionStore for MemoryStore {
5856
async fn get<T>(&self, session_id: &Id, field: &str) -> Result<Option<T>, Error>
5957
where

src/store/redis.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use async_trait::async_trait;
21
use fred::clients::Pool;
32
use fred::interfaces::{HashesInterface, KeysInterface};
43
use fred::types::{Key, Value};
@@ -78,7 +77,6 @@ where
7877
}
7978
}
8079

81-
#[async_trait]
8280
impl<C> SessionStore for RedisStore<C>
8381
where
8482
C: HashesInterface + KeysInterface + Clone + Send + Sync + 'static,

0 commit comments

Comments
 (0)