Skip to main content

DeviceQueries

Trait DeviceQueries 

Source
pub trait DeviceQueries: Database {
    // Provided methods
    async fn fetch_devices_for_user(
        &mut self,
        user_id: &UserId,
    ) -> Result<Vec<Device>, DatabaseError> { ... }
    async fn fetch_device_for_user(
        &mut self,
        user_id: &UserId,
        device_id: &DeviceId,
    ) -> Result<Option<Device>, DatabaseError> { ... }
    async fn insert_device_for_user(
        &mut self,
        user_id: &UserId,
        device_id: &DeviceId,
    ) -> Result<(), DatabaseError> { ... }
    async fn import_device(
        &mut self,
        user_id: &UserId,
        device_id: &DeviceId,
    ) -> Result<bool, DatabaseError> { ... }
    async fn insert_test_user_with_device(
        &mut self,
        user_id: &UserId,
        device_id: &DeviceId,
    ) -> Result<(), DatabaseError> { ... }
}
Expand description

Queries related to the device table.

Provided Methods§

Source

async fn fetch_devices_for_user( &mut self, user_id: &UserId, ) -> Result<Vec<Device>, DatabaseError>

Fetches all devices for a specific user

Source

async fn fetch_device_for_user( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<Option<Device>, DatabaseError>

Fetches a specific device for a specific user

Source

async fn insert_device_for_user( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<(), DatabaseError>

Inserts a new device.

NOTE: For now, the idp_id is set with the value of the device_id.

Source

async fn import_device( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<bool, DatabaseError>

Idempotently inserts a device coming from a homeserver import. idp_id is left NULL — linking to the IdP is a separate manual step. Synapse’s last_seen/ip/user_agent have no arminius equivalent and are dropped.

Source

async fn insert_test_user_with_device( &mut self, user_id: &UserId, device_id: &DeviceId, ) -> Result<(), DatabaseError>

Insert a test user with a given id (if it does not exist) with a device into the database

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T> DeviceQueries for T
where T: Database,

Make the query available on types implementing the Database trait.