2020-10-15 16:52:08 +00:00
|
|
|
use crate::db::Database;
|
|
|
|
|
|
|
|
/// A context carried through the system providing access to things
|
|
|
|
/// like the database.
|
|
|
|
#[derive(Clone)]
|
2020-11-03 20:14:15 +00:00
|
|
|
pub struct Context<'a> {
|
2020-10-17 15:18:51 +00:00
|
|
|
pub db: Database,
|
2020-11-03 20:14:15 +00:00
|
|
|
pub room_id: &'a str,
|
|
|
|
pub username: &'a str,
|
|
|
|
pub message_body: &'a str,
|
2020-10-15 16:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 20:14:15 +00:00
|
|
|
impl<'a> Context<'a> {
|
|
|
|
pub fn new(
|
|
|
|
db: &Database,
|
|
|
|
room_id: &'a str,
|
|
|
|
username: &'a str,
|
|
|
|
message_body: &'a str,
|
|
|
|
) -> Context<'a> {
|
2020-10-15 16:52:08 +00:00
|
|
|
Context {
|
2020-10-17 15:18:51 +00:00
|
|
|
db: db.clone(),
|
2020-11-03 20:14:15 +00:00
|
|
|
room_id: room_id,
|
|
|
|
username: username,
|
|
|
|
message_body: message_body,
|
2020-10-15 16:52:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|