pub struct Storage { /* private fields */ }Implementations§
Source§impl Storage
impl Storage
Sourcepub async fn migrate(&self) -> Result<(), StorageError>
pub async fn migrate(&self) -> Result<(), StorageError>
Applies bundled migrations to PostgreSQL.
Sourcepub async fn readiness(&self) -> Result<(), StorageError>
pub async fn readiness(&self) -> Result<(), StorageError>
Executes lightweight probes across PostgreSQL and Redis.
Sourcepub async fn upsert_device(
&self,
record: &DeviceRecord,
) -> Result<(), StorageError>
pub async fn upsert_device( &self, record: &DeviceRecord, ) -> Result<(), StorageError>
Registers or rotates a device key.
Sourcepub async fn record_device_key_event(
&self,
event: &DeviceKeyEvent,
) -> Result<(), StorageError>
pub async fn record_device_key_event( &self, event: &DeviceKeyEvent, ) -> Result<(), StorageError>
Persists an audit trail entry for device key material.
Sourcepub async fn latest_device_key_event(
&self,
device_id: &str,
) -> Result<Option<DeviceKeyEvent>, StorageError>
pub async fn latest_device_key_event( &self, device_id: &str, ) -> Result<Option<DeviceKeyEvent>, StorageError>
Fetches the newest device key event for a device identifier.
Sourcepub async fn record_session(
&self,
session: &SessionRecord,
) -> Result<(), StorageError>
pub async fn record_session( &self, session: &SessionRecord, ) -> Result<(), StorageError>
Creates a session binding a device to a TLS fingerprint.
Sourcepub async fn load_device(
&self,
device_id: &str,
) -> Result<DeviceRecord, StorageError>
pub async fn load_device( &self, device_id: &str, ) -> Result<DeviceRecord, StorageError>
Fetches device metadata by identifier.
Sourcepub async fn create_user(
&self,
profile: &NewUserProfile,
) -> Result<UserProfile, StorageError>
pub async fn create_user( &self, profile: &NewUserProfile, ) -> Result<UserProfile, StorageError>
Creates a new user profile entry.
Sourcepub async fn load_user(
&self,
user_id: &str,
) -> Result<UserProfile, StorageError>
pub async fn load_user( &self, user_id: &str, ) -> Result<UserProfile, StorageError>
Loads a user profile by identifier.
Sourcepub async fn load_user_by_handle(
&self,
handle: &str,
) -> Result<UserProfile, StorageError>
pub async fn load_user_by_handle( &self, handle: &str, ) -> Result<UserProfile, StorageError>
Loads a user profile by handle.
Sourcepub async fn update_user_profile(
&self,
user_id: &str,
display_name: Option<&str>,
avatar_url: Option<&str>,
) -> Result<(), StorageError>
pub async fn update_user_profile( &self, user_id: &str, display_name: Option<&str>, avatar_url: Option<&str>, ) -> Result<(), StorageError>
Applies partial updates to user profile metadata.
Sourcepub async fn create_group(&self, group: &ChatGroup) -> Result<(), StorageError>
pub async fn create_group(&self, group: &ChatGroup) -> Result<(), StorageError>
Creates a chat group entry and enrolls the owner as a member.
Sourcepub async fn add_group_member(
&self,
member: &GroupMember,
) -> Result<(), StorageError>
pub async fn add_group_member( &self, member: &GroupMember, ) -> Result<(), StorageError>
Adds or updates group membership information.
Sourcepub async fn remove_group_member(
&self,
group_id: &str,
device_id: &str,
) -> Result<(), StorageError>
pub async fn remove_group_member( &self, group_id: &str, device_id: &str, ) -> Result<(), StorageError>
Removes a member from the given group.
Sourcepub async fn list_group_members(
&self,
group_id: &str,
) -> Result<Vec<GroupMember>, StorageError>
pub async fn list_group_members( &self, group_id: &str, ) -> Result<Vec<GroupMember>, StorageError>
Lists all members of a group ordered by join time.
Sourcepub async fn load_group(
&self,
group_id: &str,
) -> Result<ChatGroup, StorageError>
pub async fn load_group( &self, group_id: &str, ) -> Result<ChatGroup, StorageError>
Loads group metadata by identifier.
Sourcepub async fn list_groups_for_device(
&self,
device_id: &str,
) -> Result<Vec<ChatGroup>, StorageError>
pub async fn list_groups_for_device( &self, device_id: &str, ) -> Result<Vec<ChatGroup>, StorageError>
Lists groups that include the target device.
Sourcepub async fn upsert_federation_peer(
&self,
peer: &FederationPeerRecord,
) -> Result<(), StorageError>
pub async fn upsert_federation_peer( &self, peer: &FederationPeerRecord, ) -> Result<(), StorageError>
Upserts federation peer descriptors for S2S routing.
Sourcepub async fn load_federation_peer(
&self,
domain: &str,
) -> Result<FederationPeerRecord, StorageError>
pub async fn load_federation_peer( &self, domain: &str, ) -> Result<FederationPeerRecord, StorageError>
Loads a federation peer by domain.
Sourcepub async fn list_federation_peers(
&self,
) -> Result<Vec<FederationPeerRecord>, StorageError>
pub async fn list_federation_peers( &self, ) -> Result<Vec<FederationPeerRecord>, StorageError>
Enumerates all known federation peers.
Sourcepub async fn set_federation_peer_status(
&self,
domain: &str,
status: FederationPeerStatus,
) -> Result<(), StorageError>
pub async fn set_federation_peer_status( &self, domain: &str, status: FederationPeerStatus, ) -> Result<(), StorageError>
Sets the peer status and refresh timestamp.
Sourcepub async fn enqueue_relay(
&self,
envelope: &RelayEnvelope,
) -> Result<(), StorageError>
pub async fn enqueue_relay( &self, envelope: &RelayEnvelope, ) -> Result<(), StorageError>
Schedules an encrypted relay envelope for delivery.
Sourcepub async fn claim_envelopes(
&self,
channel_id: &str,
limit: i64,
) -> Result<Vec<RelayEnvelope>, StorageError>
pub async fn claim_envelopes( &self, channel_id: &str, limit: i64, ) -> Result<Vec<RelayEnvelope>, StorageError>
Claims pending relay envelopes for a channel.
Sourcepub async fn store_inbox_offset(
&self,
offset: &InboxOffset,
) -> Result<(), StorageError>
pub async fn store_inbox_offset( &self, offset: &InboxOffset, ) -> Result<(), StorageError>
Stores the last delivered envelope reference for an entity/channel pair.
Sourcepub async fn read_inbox_offset(
&self,
entity_id: &str,
channel_id: &str,
) -> Result<Option<InboxOffset>, StorageError>
pub async fn read_inbox_offset( &self, entity_id: &str, channel_id: &str, ) -> Result<Option<InboxOffset>, StorageError>
Reads the stored inbox offset if present.
Sourcepub async fn store_idempotency(
&self,
key: &IdempotencyKey,
) -> Result<(), StorageError>
pub async fn store_idempotency( &self, key: &IdempotencyKey, ) -> Result<(), StorageError>
Records an idempotency key for deduplication.
Sourcepub async fn publish_presence(
&self,
snapshot: &PresenceSnapshot,
) -> Result<(), StorageError>
pub async fn publish_presence( &self, snapshot: &PresenceSnapshot, ) -> Result<(), StorageError>
Publishes local presence information into Redis.
Sourcepub async fn read_presence(
&self,
entity: &str,
) -> Result<Option<PresenceSnapshot>, StorageError>
pub async fn read_presence( &self, entity: &str, ) -> Result<Option<PresenceSnapshot>, StorageError>
Reads presence state from Redis.
Sourcepub async fn register_route(
&self,
entity: &str,
session_id: &str,
ttl_seconds: i64,
) -> Result<(), StorageError>
pub async fn register_route( &self, entity: &str, session_id: &str, ttl_seconds: i64, ) -> Result<(), StorageError>
Registers a routing entry in Redis for direct message delivery.
Sourcepub async fn clear_route(&self, entity: &str) -> Result<(), StorageError>
pub async fn clear_route(&self, entity: &str) -> Result<(), StorageError>
Removes a routing entry from Redis.