messing with trait objects

This commit is contained in:
Timo Kösters 2022-10-05 12:45:54 +02:00 committed by Nyaaori
parent 8708cd3b63
commit face766e0f
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
61 changed files with 623 additions and 544 deletions

View file

@ -4,8 +4,8 @@ pub mod typing;
pub trait Data: presence::Data + read_receipt::Data + typing::Data {}
pub struct Service<D: Data> {
pub presence: presence::Service<D>,
pub read_receipt: read_receipt::Service<D>,
pub typing: typing::Service<D>,
pub struct Service {
pub presence: presence::Service,
pub read_receipt: read_receipt::Service,
pub typing: typing::Service,
}

View file

@ -6,11 +6,11 @@ use ruma::{RoomId, UserId, events::presence::PresenceEvent};
use crate::Result;
pub struct Service<D: Data> {
db: D,
pub struct Service {
db: Box<dyn Data>,
}
impl<D: Data> Service<D> {
impl Service {
/// Adds a presence event which will be saved until a new event replaces it.
///
/// Note: This method takes a RoomId because presence updates are always bound to rooms to

View file

@ -4,11 +4,11 @@ pub use data::Data;
use ruma::{RoomId, UserId, events::receipt::ReceiptEvent, serde::Raw};
use crate::Result;
pub struct Service<D: Data> {
db: D,
pub struct Service {
db: Box<dyn Data>,
}
impl<D: Data> Service<D> {
impl Service {
/// Replaces the previous read receipt.
pub fn readreceipt_update(
&self,

View file

@ -4,11 +4,11 @@ use ruma::{UserId, RoomId, events::SyncEphemeralRoomEvent};
use crate::Result;
pub struct Service<D: Data> {
db: D,
pub struct Service {
db: Box<dyn Data>,
}
impl<D: Data> Service<D> {
impl Service {
/// Sets a user as typing until the timeout timestamp is reached or roomtyping_remove is
/// called.
pub fn typing_add(&self, user_id: &UserId, room_id: &RoomId, timeout: u64) -> Result<()> {