[][src]Struct sudoku_backend::ops::setup::ActivityCache

pub struct ActivityCache { /* fields omitted */ }

A time-limited cache of session IDs for "currently active" indicator. Refer to doc/check.rs for more details.

Examples

#[get("/endpoint")]
fn endpoint(db: DatabaseConnection, ac: State<ActivityCache>) -> String {
    // Get the ID of this session
    ac.register_activity(12);

    // rest of funxionality is outside the scope of this document
    funxion_result
}

#[get("/users_active")]
fn users_active(ac: State<ActivityCache>) -> String {
    ac.active_users().to_string()
}

fn main() {
    let database_file: (String, PathBuf) = /* obtained elsewhere */;
    rocket::ignite()
        .manage(DatabaseConnection::initialise(&database_file))
        .manage(ActivityCache::new(*ACTIVITY_TIMEOUT_DEFAULT))
        .mount("/", routes![endpoint, users_active])
        .launch();
}

Methods

impl ActivityCache
[src]

Create a cache timing out after the specified duration.

Mark the specified session ID as last active now.

Get how many users can be considered "active", i.e. amount of sessions last active at most the previously-specified amount of time before now.

Trait Implementations

impl Clone for ActivityCache
[src]

Performs copy-assignment from source. Read more

impl Debug for ActivityCache
[src]

Auto Trait Implementations

impl Send for ActivityCache

impl Sync for ActivityCache

Blanket Implementations

impl<T> From for T
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> IntoSql for T
[src]

Convert self to an expression for Diesel's query builder. Read more

Convert &self to an expression for Diesel's query builder. Read more