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-10-17 15:18:51 +00:00
|
|
|
pub struct Context {
|
|
|
|
pub db: Database,
|
|
|
|
pub room_id: String,
|
|
|
|
pub username: String,
|
|
|
|
pub message_body: String,
|
2020-10-15 16:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 15:18:51 +00:00
|
|
|
impl Context {
|
|
|
|
pub fn new(db: &Database, room_id: &str, username: &str, message_body: &str) -> Context {
|
2020-10-15 16:52:08 +00:00
|
|
|
Context {
|
2020-10-17 15:18:51 +00:00
|
|
|
db: db.clone(),
|
|
|
|
room_id: room_id.to_owned(),
|
|
|
|
username: username.to_owned(),
|
|
|
|
message_body: message_body.to_owned(),
|
2020-10-15 16:52:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|