2022-10-08 13:02:52 +02:00
|
|
|
use ruma::ServerName;
|
|
|
|
|
2024-04-22 17:27:54 -04:00
|
|
|
use super::{Destination, SendingEventType};
|
2022-10-08 13:02:52 +02:00
|
|
|
use crate::Result;
|
|
|
|
|
2024-04-22 17:27:54 -04:00
|
|
|
type OutgoingSendingIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, Destination, SendingEventType)>> + 'a>;
|
2023-11-29 21:36:02 -05:00
|
|
|
type SendingEventTypeIter<'a> = Box<dyn Iterator<Item = Result<(Vec<u8>, SendingEventType)>> + 'a>;
|
|
|
|
|
2024-04-22 23:48:57 -04:00
|
|
|
pub(crate) trait Data: Send + Sync {
|
2023-11-29 21:36:02 -05:00
|
|
|
fn active_requests(&self) -> OutgoingSendingIter<'_>;
|
2024-04-22 17:27:54 -04:00
|
|
|
fn active_requests_for(&self, destination: &Destination) -> SendingEventTypeIter<'_>;
|
2022-10-08 13:02:52 +02:00
|
|
|
fn delete_active_request(&self, key: Vec<u8>) -> Result<()>;
|
2024-04-22 17:27:54 -04:00
|
|
|
fn delete_all_active_requests_for(&self, destination: &Destination) -> Result<()>;
|
2024-04-22 23:54:56 -04:00
|
|
|
|
|
|
|
/// TODO: use this?
|
|
|
|
#[allow(dead_code)]
|
2024-04-22 17:27:54 -04:00
|
|
|
fn delete_all_requests_for(&self, destination: &Destination) -> Result<()>;
|
|
|
|
fn queue_requests(&self, requests: &[(&Destination, SendingEventType)]) -> Result<Vec<Vec<u8>>>;
|
2022-10-08 13:02:52 +02:00
|
|
|
fn queued_requests<'a>(
|
2024-04-22 17:27:54 -04:00
|
|
|
&'a self, destination: &Destination,
|
2022-10-08 13:02:52 +02:00
|
|
|
) -> Box<dyn Iterator<Item = Result<(SendingEventType, Vec<u8>)>> + 'a>;
|
|
|
|
fn mark_as_active(&self, events: &[(SendingEventType, Vec<u8>)]) -> Result<()>;
|
|
|
|
fn set_latest_educount(&self, server_name: &ServerName, educount: u64) -> Result<()>;
|
|
|
|
fn get_latest_educount(&self, server_name: &ServerName) -> Result<u64>;
|
|
|
|
}
|