pub trait ToDeviceQueries: Database {
// Provided methods
async fn insert_to_device_messages(
&mut self,
event_type: ToDeviceEventType,
sender: &UserId,
messages: Vec<ToDeviceMessage>,
) -> Result<PgQueryResult, DatabaseError> { ... }
async fn insert_to_device_transaction(
&mut self,
origin: &ServerName,
txnid: &TransactionId,
) -> Result<(), DatabaseError> { ... }
async fn to_device_transaction_exists(
&mut self,
origin: &ServerName,
txnid: &TransactionId,
) -> Result<bool, DatabaseError> { ... }
async fn fetch_sync_todevice_messages(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
from: StreamId,
) -> Result<Vec<SyncToDeviceEvent>, DatabaseError> { ... }
async fn import_to_device_message(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
sender: &UserId,
event_type: &ToDeviceEventType,
content: Value,
) -> Result<bool, DatabaseError> { ... }
async fn delete_synced_todevice_messages(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
delete_to_inclusive: StreamId,
) -> Result<PgQueryResult, DatabaseError> { ... }
}Expand description
Queries related to the room table.
Provided Methods§
Sourceasync fn insert_to_device_messages(
&mut self,
event_type: ToDeviceEventType,
sender: &UserId,
messages: Vec<ToDeviceMessage>,
) -> Result<PgQueryResult, DatabaseError>
async fn insert_to_device_messages( &mut self, event_type: ToDeviceEventType, sender: &UserId, messages: Vec<ToDeviceMessage>, ) -> Result<PgQueryResult, DatabaseError>
Inserts a list of send-to-device messages into the database
Sourceasync fn insert_to_device_transaction(
&mut self,
origin: &ServerName,
txnid: &TransactionId,
) -> Result<(), DatabaseError>
async fn insert_to_device_transaction( &mut self, origin: &ServerName, txnid: &TransactionId, ) -> Result<(), DatabaseError>
Insert a to-device transaction, used in federation
Sourceasync fn to_device_transaction_exists(
&mut self,
origin: &ServerName,
txnid: &TransactionId,
) -> Result<bool, DatabaseError>
async fn to_device_transaction_exists( &mut self, origin: &ServerName, txnid: &TransactionId, ) -> Result<bool, DatabaseError>
Returns true if a homeserver has already used the transaction ID for to-device messages
Sourceasync fn fetch_sync_todevice_messages(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
from: StreamId,
) -> Result<Vec<SyncToDeviceEvent>, DatabaseError>
async fn fetch_sync_todevice_messages( &mut self, user_id: &UserId, device_id: &DeviceId, from: StreamId, ) -> Result<Vec<SyncToDeviceEvent>, DatabaseError>
Gets the todevice messages sent to a specific device since last sync.
Sourceasync fn import_to_device_message(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
sender: &UserId,
event_type: &ToDeviceEventType,
content: Value,
) -> Result<bool, DatabaseError>
async fn import_to_device_message( &mut self, user_id: &UserId, device_id: &DeviceId, sender: &UserId, event_type: &ToDeviceEventType, content: Value, ) -> Result<bool, DatabaseError>
Imports a single to-device message from a homeserver export. Returns
true if a row was inserted.
arminius’s stream_id is a per-row UNIQUE sync cursor, but synapse
shares one device_inbox stream_id across an entire fan-out (many
recipient devices), so it cannot be preserved. Each recipient row gets a
fresh per-row stream_id from the device_message_streamids sequence
via the column default, exactly like a live send, so no sequence
realignment is needed after the import.
If the recipient of the message does not exist, Ok(false) is returned.
Sourceasync fn delete_synced_todevice_messages(
&mut self,
user_id: &UserId,
device_id: &DeviceId,
delete_to_inclusive: StreamId,
) -> Result<PgQueryResult, DatabaseError>
async fn delete_synced_todevice_messages( &mut self, user_id: &UserId, device_id: &DeviceId, delete_to_inclusive: StreamId, ) -> Result<PgQueryResult, DatabaseError>
When we are syncing past old send-to-device messages, these old messages should be deleted from the server, per the spec.
See https://spec.matrix.org/v1.15/client-server-api/#server-behaviour-6.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".