Skip to content

Commit 969ba7d

Browse files
committed
rename SqliteStore -> SqliteSessionStore
1 parent 293cb37 commit 969ba7d

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! through a feature flag.
66
//!
77
//! For now, see the documentation for
8-
//! [`SqliteStore`](crate::SqliteStore)
8+
//! [`SqliteStore`](crate::SqliteSessionStore)
99
#![forbid(unsafe_code, future_incompatible)]
1010
#![deny(
1111
missing_debug_implementations,
@@ -19,4 +19,4 @@
1919
#[cfg(feature = "sqlite")]
2020
mod sqlite;
2121
#[cfg(feature = "sqlite")]
22-
pub use sqlite::SqliteStore;
22+
pub use sqlite::SqliteSessionStore;

src/sqlite.rs

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use std::time::Duration;
77
/// sqlx sqlite session store for async-sessions
88
///
99
/// ```rust
10-
/// use async_sqlx_session::SqliteStore;
10+
/// use async_sqlx_session::SqliteSessionStore;
1111
/// use async_session::{Session, SessionStore};
1212
/// use std::time::Duration;
1313
///
1414
/// # fn main() -> async_session::Result { async_std::task::block_on(async {
15-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
15+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
1616
/// store.migrate().await?;
1717
/// store.spawn_cleanup_task(Duration::from_secs(60 * 60));
1818
///
@@ -25,23 +25,23 @@ use std::time::Duration;
2525
/// # Ok(()) }) }
2626
///
2727
#[derive(Clone, Debug)]
28-
pub struct SqliteStore {
28+
pub struct SqliteSessionStore {
2929
client: SqlitePool,
3030
table_name: String,
3131
}
3232

33-
impl SqliteStore {
34-
/// constructs a new SqliteStore from an existing
33+
impl SqliteSessionStore {
34+
/// constructs a new SqliteSessionStore from an existing
3535
/// sqlx::SqlitePool. the default table name for this session
3636
/// store will be "async_sessions". To override this, chain this
37-
/// with [`with_table_name`](crate::SqliteStore::with_table_name).
37+
/// with [`with_table_name`](crate::SqliteSessionStore::with_table_name).
3838
///
3939
/// ```rust
40-
/// # use async_sqlx_session::SqliteStore;
40+
/// # use async_sqlx_session::SqliteSessionStore;
4141
/// # use async_session::Result;
4242
/// # fn main() -> Result { async_std::task::block_on(async {
4343
/// let pool = sqlx::SqlitePool::new("sqlite:%3Amemory:").await.unwrap();
44-
/// let store = SqliteStore::from_client(pool)
44+
/// let store = SqliteSessionStore::from_client(pool)
4545
/// .with_table_name("custom_table_name");
4646
/// store.migrate().await;
4747
/// # Ok(()) }) }
@@ -53,40 +53,40 @@ impl SqliteStore {
5353
}
5454
}
5555

56-
/// Constructs a new SqliteStore from a sqlite: database url. note
56+
/// Constructs a new SqliteSessionStore from a sqlite: database url. note
5757
/// that this documentation uses the special `:memory:` sqlite
5858
/// database for convenient testing, but a real application would
5959
/// use a path like `sqlite:///path/to/database.db`. The default
6060
/// table name for this session store will be "async_sessions". To
6161
/// override this, either chain with
62-
/// [`with_table_name`](crate::SqliteStore::with_table_name) or
62+
/// [`with_table_name`](crate::SqliteSessionStore::with_table_name) or
6363
/// use
64-
/// [`new_with_table_name`](crate::SqliteStore::new_with_table_name)
64+
/// [`new_with_table_name`](crate::SqliteSessionStore::new_with_table_name)
6565
///
6666
/// ```rust
67-
/// # use async_sqlx_session::SqliteStore;
67+
/// # use async_sqlx_session::SqliteSessionStore;
6868
/// # use async_session::Result;
6969
/// # fn main() -> Result { async_std::task::block_on(async {
70-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
70+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
7171
/// store.migrate().await;
7272
/// # Ok(()) }) }
7373
/// ```
7474
pub async fn new(database_url: &str) -> sqlx::Result<Self> {
7575
Ok(Self::from_client(SqlitePool::new(database_url).await?))
7676
}
7777

78-
/// constructs a new SqliteStore from a sqlite: database url. the
78+
/// constructs a new SqliteSessionStore from a sqlite: database url. the
7979
/// default table name for this session store will be
8080
/// "async_sessions". To override this, either chain with
81-
/// [`with_table_name`](crate::SqliteStore::with_table_name) or
81+
/// [`with_table_name`](crate::SqliteSessionStore::with_table_name) or
8282
/// use
83-
/// [`new_with_table_name`](crate::SqliteStore::new_with_table_name)
83+
/// [`new_with_table_name`](crate::SqliteSessionStore::new_with_table_name)
8484
///
8585
/// ```rust
86-
/// # use async_sqlx_session::SqliteStore;
86+
/// # use async_sqlx_session::SqliteSessionStore;
8787
/// # use async_session::Result;
8888
/// # fn main() -> Result { async_std::task::block_on(async {
89-
/// let store = SqliteStore::new_with_table_name("sqlite:%3Amemory:", "custom_table_name").await?;
89+
/// let store = SqliteSessionStore::new_with_table_name("sqlite:%3Amemory:", "custom_table_name").await?;
9090
/// store.migrate().await;
9191
/// # Ok(()) }) }
9292
/// ```
@@ -97,20 +97,20 @@ impl SqliteStore {
9797
/// Chainable method to add a custom table name. This will panic
9898
/// if the table name is not `[a-zA-Z0-9_-]+`.
9999
/// ```rust
100-
/// # use async_sqlx_session::SqliteStore;
100+
/// # use async_sqlx_session::SqliteSessionStore;
101101
/// # use async_session::Result;
102102
/// # fn main() -> Result { async_std::task::block_on(async {
103-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?
103+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?
104104
/// .with_table_name("custom_name");
105105
/// store.migrate().await;
106106
/// # Ok(()) }) }
107107
/// ```
108108
///
109109
/// ```should_panic
110-
/// # use async_sqlx_session::SqliteStore;
110+
/// # use async_sqlx_session::SqliteSessionStore;
111111
/// # use async_session::Result;
112112
/// # fn main() -> Result { async_std::task::block_on(async {
113-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?
113+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?
114114
/// .with_table_name("johnny (); drop users;");
115115
/// # Ok(()) }) }
116116
/// ```
@@ -137,10 +137,10 @@ impl SqliteStore {
137137
/// exactly-once modifications to the schema of the session table
138138
/// on breaking releases.
139139
/// ```rust
140-
/// # use async_sqlx_session::SqliteStore;
140+
/// # use async_sqlx_session::SqliteSessionStore;
141141
/// # use async_session::{Result, SessionStore, Session};
142142
/// # fn main() -> Result { async_std::task::block_on(async {
143-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
143+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
144144
/// assert!(store.count().await.is_err());
145145
/// store.migrate().await?;
146146
/// store.store_session(Session::new()).await;
@@ -180,11 +180,11 @@ impl SqliteStore {
180180
/// Spawns an async_std::task that clears out stale (expired)
181181
/// sessions on a periodic basis.
182182
/// ```rust
183-
/// # use async_sqlx_session::SqliteStore;
183+
/// # use async_sqlx_session::SqliteSessionStore;
184184
/// # use async_session::{Result, SessionStore, Session};
185185
/// # use std::time::Duration;
186186
/// # fn main() -> Result { async_std::task::block_on(async {
187-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
187+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
188188
/// store.migrate().await?;
189189
/// store.spawn_cleanup_task(Duration::from_secs(1));
190190
/// let mut session = Session::new();
@@ -210,10 +210,10 @@ impl SqliteStore {
210210
/// Performs a one-time cleanup task that clears out stale
211211
/// (expired) sessions. You may want to call this from cron.
212212
/// ```rust
213-
/// # use async_sqlx_session::SqliteStore;
213+
/// # use async_sqlx_session::SqliteSessionStore;
214214
/// # use async_session::{chrono::{Utc,Duration}, Result, SessionStore, Session};
215215
/// # fn main() -> Result { async_std::task::block_on(async {
216-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
216+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
217217
/// store.migrate().await?;
218218
/// let mut session = Session::new();
219219
/// session.set_expiry(Utc::now() - Duration::seconds(5));
@@ -242,11 +242,11 @@ impl SqliteStore {
242242
/// expired sessions
243243
///
244244
/// ```rust
245-
/// # use async_sqlx_session::SqliteStore;
245+
/// # use async_sqlx_session::SqliteSessionStore;
246246
/// # use async_session::{Result, SessionStore, Session};
247247
/// # use std::time::Duration;
248248
/// # fn main() -> Result { async_std::task::block_on(async {
249-
/// let store = SqliteStore::new("sqlite:%3Amemory:").await?;
249+
/// let store = SqliteSessionStore::new("sqlite:%3Amemory:").await?;
250250
/// store.migrate().await?;
251251
/// assert_eq!(store.count().await?, 0);
252252
/// store.store_session(Session::new()).await;
@@ -265,7 +265,7 @@ impl SqliteStore {
265265
}
266266

267267
#[async_trait]
268-
impl SessionStore for SqliteStore {
268+
impl SessionStore for SqliteSessionStore {
269269
async fn load_session(&self, cookie_value: String) -> Option<Session> {
270270
let id = Session::id_from_cookie_value(&cookie_value).ok()?;
271271
let mut connection = self.connection().await.ok()?;
@@ -342,14 +342,14 @@ impl SessionStore for SqliteStore {
342342
mod tests {
343343
use super::*;
344344

345-
async fn test_store() -> SqliteStore {
346-
let store = SqliteStore::new("sqlite:%3Amemory:")
345+
async fn test_store() -> SqliteSessionStore {
346+
let store = SqliteSessionStore::new("sqlite:%3Amemory:")
347347
.await
348-
.expect("building a sqlite :memory: SqliteStore");
348+
.expect("building a sqlite :memory: SqliteSessionStore");
349349
store
350350
.migrate()
351351
.await
352-
.expect("migrating a brand new :memory: SqliteStore");
352+
.expect("migrating a brand new :memory: SqliteSessionStore");
353353
store
354354
}
355355

0 commit comments

Comments
 (0)