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 read_user_blob(
&self,
user_id: &str,
key: &str,
) -> Result<Option<String>, StorageError>
pub async fn read_user_blob( &self, user_id: &str, key: &str, ) -> Result<Option<String>, StorageError>
Reads a user-scoped blob entry.
Sourcepub async fn write_user_blob(
&self,
user_id: &str,
key: &str,
payload: &str,
) -> Result<(), StorageError>
pub async fn write_user_blob( &self, user_id: &str, key: &str, payload: &str, ) -> Result<(), StorageError>
Upserts a user-scoped blob entry.
Sourcepub async fn insert_server_secret(
&self,
record: &ServerSecretRecord,
) -> Result<(), StorageError>
pub async fn insert_server_secret( &self, record: &ServerSecretRecord, ) -> Result<(), StorageError>
Inserts a server-scoped secret version.
Sourcepub async fn active_server_secrets(
&self,
name: &str,
moment: DateTime<Utc>,
) -> Result<Vec<ServerSecretRecord>, StorageError>
pub async fn active_server_secrets( &self, name: &str, moment: DateTime<Utc>, ) -> Result<Vec<ServerSecretRecord>, StorageError>
Loads active secret material for a given name.
Sourcepub async fn latest_server_secret_version(
&self,
name: &str,
) -> Result<i64, StorageError>
pub async fn latest_server_secret_version( &self, name: &str, ) -> Result<i64, StorageError>
Returns the most recent version number for a secret name.
Sourcepub async fn delete_expired_server_secrets(
&self,
name: &str,
threshold: DateTime<Utc>,
) -> Result<u64, StorageError>
pub async fn delete_expired_server_secrets( &self, name: &str, threshold: DateTime<Utc>, ) -> Result<u64, StorageError>
Deletes expired secret versions.
Sourcepub async fn create_pairing_token(
&self,
user_id: &str,
issuer_device_id: &str,
ttl_seconds: i64,
) -> Result<PairingTokenIssued, StorageError>
pub async fn create_pairing_token( &self, user_id: &str, issuer_device_id: &str, ttl_seconds: i64, ) -> Result<PairingTokenIssued, StorageError>
Creates a short-lived pairing code bound to an issuer device.
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 apply_device_key_rotation(
&self,
rotation: &DeviceRotationRecord<'_>,
) -> Result<(), StorageError>
pub async fn apply_device_key_rotation( &self, rotation: &DeviceRotationRecord<'_>, ) -> Result<(), StorageError>
Applies a device key rotation atomically.
Sourcepub async fn claim_pairing_token(
&self,
pair_code: &str,
device_id: &str,
public_key: &[u8],
) -> Result<PairingClaimResult, StorageError>
pub async fn claim_pairing_token( &self, pair_code: &str, device_id: &str, public_key: &[u8], ) -> Result<PairingClaimResult, StorageError>
Claims a pairing token and registers a new device for the associated user.
Sourcepub async fn invalidate_expired_pairings(&self) -> Result<u64, StorageError>
pub async fn invalidate_expired_pairings(&self) -> Result<u64, StorageError>
Removes expired or exhausted pairing tokens.
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_session(
&self,
session_id: &str,
) -> Result<SessionRecord, StorageError>
pub async fn load_session( &self, session_id: &str, ) -> Result<SessionRecord, StorageError>
Loads a persisted session by identifier.
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 load_device_pq_keys(
&self,
device_id: &str,
) -> Result<Option<DevicePqKeys>, StorageError>
pub async fn load_device_pq_keys( &self, device_id: &str, ) -> Result<Option<DevicePqKeys>, StorageError>
Loads stored post-quantum key material for a device when available.
Sourcepub async fn upsert_device_pq_keys(
&self,
keys: &DevicePqKeys,
) -> Result<(), StorageError>
pub async fn upsert_device_pq_keys( &self, keys: &DevicePqKeys, ) -> Result<(), StorageError>
Upserts post-quantum key material for a device.
Sourcepub async fn count_active_devices(
&self,
user_id: &str,
) -> Result<i64, StorageError>
pub async fn count_active_devices( &self, user_id: &str, ) -> Result<i64, StorageError>
Counts active devices registered for a user.
Sourcepub async fn list_devices_for_user(
&self,
user_id: &str,
) -> Result<Vec<DeviceRecord>, StorageError>
pub async fn list_devices_for_user( &self, user_id: &str, ) -> Result<Vec<DeviceRecord>, StorageError>
Lists devices associated with a user ordered by creation time.
Sourcepub async fn activate_device(&self, device_id: &str) -> Result<(), StorageError>
pub async fn activate_device(&self, device_id: &str) -> Result<(), StorageError>
Marks a device as active.
Sourcepub async fn deactivate_device(
&self,
device_id: &str,
) -> Result<(), StorageError>
pub async fn deactivate_device( &self, device_id: &str, ) -> Result<(), StorageError>
Marks a device as revoked.
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 update_user_avatar(
&self,
user_id: &str,
avatar_url: &str,
) -> Result<(), StorageError>
pub async fn update_user_avatar( &self, user_id: &str, avatar_url: &str, ) -> Result<(), StorageError>
Updates user avatar URL
Sourcepub async fn load_user_by_federated_id(
&self,
handle: &str,
domain: &str,
) -> Result<UserProfile, StorageError>
pub async fn load_user_by_federated_id( &self, handle: &str, domain: &str, ) -> Result<UserProfile, StorageError>
Loads user by handle@domain
Sourcepub async fn cache_remote_user(
&self,
profile: &RemoteUserProfile,
) -> Result<(), StorageError>
pub async fn cache_remote_user( &self, profile: &RemoteUserProfile, ) -> Result<(), StorageError>
Caches remote user profile
Sourcepub async fn load_remote_user_cache(
&self,
user_id: &str,
) -> Result<Option<RemoteUserProfile>, StorageError>
pub async fn load_remote_user_cache( &self, user_id: &str, ) -> Result<Option<RemoteUserProfile>, StorageError>
Loads cached remote user profile
Sourcepub async fn update_federation_peer_status(
&self,
status: &FederationPeerConnectionStatus,
) -> Result<(), StorageError>
pub async fn update_federation_peer_status( &self, status: &FederationPeerConnectionStatus, ) -> Result<(), StorageError>
Updates federation peer status
Sourcepub async fn create_federated_friend_request(
&self,
request: &FederatedFriendRequest,
) -> Result<(), StorageError>
pub async fn create_federated_friend_request( &self, request: &FederatedFriendRequest, ) -> Result<(), StorageError>
Creates federated friend request
Sourcepub async fn update_federated_friend_request_status(
&self,
request_id: &str,
status: &str,
) -> Result<(), StorageError>
pub async fn update_federated_friend_request_status( &self, request_id: &str, status: &str, ) -> Result<(), StorageError>
Updates federated friend request status
Sourcepub async fn list_federated_friend_requests(
&self,
user_id: &str,
incoming: bool,
) -> Result<Vec<FederatedFriendRequest>, StorageError>
pub async fn list_federated_friend_requests( &self, user_id: &str, incoming: bool, ) -> Result<Vec<FederatedFriendRequest>, StorageError>
Lists federated friend requests for user
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 enqueue_federation_outbox(
&self,
record: &FederationOutboxInsert<'_>,
) -> Result<(), StorageError>
pub async fn enqueue_federation_outbox( &self, record: &FederationOutboxInsert<'_>, ) -> Result<(), StorageError>
Registers a federation event for outbound delivery.
Sourcepub async fn claim_federation_outbox(
&self,
limit: i64,
lease: Duration,
now: DateTime<Utc>,
) -> Result<Vec<FederationOutboxMessage>, StorageError>
pub async fn claim_federation_outbox( &self, limit: i64, lease: Duration, now: DateTime<Utc>, ) -> Result<Vec<FederationOutboxMessage>, StorageError>
Claims due federation events and leases them for processing.
Sourcepub async fn delete_federation_outbox(
&self,
outbox_id: &str,
) -> Result<(), StorageError>
pub async fn delete_federation_outbox( &self, outbox_id: &str, ) -> Result<(), StorageError>
Removes a federation outbox entry once delivery succeeds.
Sourcepub async fn reschedule_federation_outbox(
&self,
outbox_id: &str,
delay: Duration,
now: DateTime<Utc>,
error: Option<&str>,
) -> Result<(), StorageError>
pub async fn reschedule_federation_outbox( &self, outbox_id: &str, delay: Duration, now: DateTime<Utc>, error: Option<&str>, ) -> Result<(), StorageError>
Reschedules a federation outbox entry after a failed attempt.
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<bool, StorageError>
pub async fn store_idempotency( &self, key: &IdempotencyKey, ) -> Result<bool, StorageError>
Records an idempotency key for deduplication.
Sourcepub async fn create_friend_request(
&self,
id: &str,
from_user_id: &str,
to_user_id: &str,
message: Option<&str>,
) -> Result<FriendRequest, StorageError>
pub async fn create_friend_request( &self, id: &str, from_user_id: &str, to_user_id: &str, message: Option<&str>, ) -> Result<FriendRequest, StorageError>
Creates a friend request
Sourcepub async fn get_friend_request(
&self,
id: &str,
) -> Result<FriendRequest, StorageError>
pub async fn get_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>
Gets a friend request by ID
Sourcepub async fn list_incoming_friend_requests(
&self,
user_id: &str,
) -> Result<Vec<FriendRequest>, StorageError>
pub async fn list_incoming_friend_requests( &self, user_id: &str, ) -> Result<Vec<FriendRequest>, StorageError>
Lists incoming friend requests for a user
Sourcepub async fn list_outgoing_friend_requests(
&self,
user_id: &str,
) -> Result<Vec<FriendRequest>, StorageError>
pub async fn list_outgoing_friend_requests( &self, user_id: &str, ) -> Result<Vec<FriendRequest>, StorageError>
Lists outgoing friend requests from a user
Sourcepub async fn accept_friend_request(
&self,
id: &str,
) -> Result<FriendRequest, StorageError>
pub async fn accept_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>
Accepts a friend request
Sourcepub async fn reject_friend_request(
&self,
id: &str,
) -> Result<FriendRequest, StorageError>
pub async fn reject_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>
Rejects a friend request
Sourcepub async fn delete_friend_request(&self, id: &str) -> Result<(), StorageError>
pub async fn delete_friend_request(&self, id: &str) -> Result<(), StorageError>
Deletes a friend request
Sourcepub async fn friend_request_exists(
&self,
from_user_id: &str,
to_user_id: &str,
) -> Result<Option<FriendRequest>, StorageError>
pub async fn friend_request_exists( &self, from_user_id: &str, to_user_id: &str, ) -> Result<Option<FriendRequest>, StorageError>
Checks if a friend request exists between two users
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.
Auto Trait Implementations§
impl Freeze for Storage
impl !RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl !UnwindSafe for Storage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more