Storage

Struct Storage 

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub async fn migrate(&self) -> Result<(), StorageError>

Applies bundled migrations to PostgreSQL.

Source

pub async fn readiness(&self) -> Result<(), StorageError>

Executes lightweight probes across PostgreSQL and Redis.

Source

pub async fn read_user_blob( &self, user_id: &str, key: &str, ) -> Result<Option<String>, StorageError>

Reads a user-scoped blob entry.

Source

pub async fn write_user_blob( &self, user_id: &str, key: &str, payload: &str, ) -> Result<(), StorageError>

Upserts a user-scoped blob entry.

Source

pub async fn insert_server_secret( &self, record: &ServerSecretRecord, ) -> Result<(), StorageError>

Inserts a server-scoped secret version.

Source

pub async fn active_server_secrets( &self, name: &str, moment: DateTime<Utc>, ) -> Result<Vec<ServerSecretRecord>, StorageError>

Loads active secret material for a given name.

Source

pub async fn latest_server_secret_version( &self, name: &str, ) -> Result<i64, StorageError>

Returns the most recent version number for a secret name.

Source

pub async fn delete_expired_server_secrets( &self, name: &str, threshold: DateTime<Utc>, ) -> Result<u64, StorageError>

Deletes expired secret versions.

Source

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.

Source

pub async fn upsert_device( &self, record: &DeviceRecord, ) -> Result<(), StorageError>

Registers or rotates a device key.

Source

pub async fn record_device_key_event( &self, event: &DeviceKeyEvent, ) -> Result<(), StorageError>

Persists an audit trail entry for device key material.

Source

pub async fn apply_device_key_rotation( &self, rotation: &DeviceRotationRecord<'_>, ) -> Result<(), StorageError>

Applies a device key rotation atomically.

Source

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.

Source

pub async fn invalidate_expired_pairings(&self) -> Result<u64, StorageError>

Removes expired or exhausted pairing tokens.

Source

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.

Source

pub async fn record_session( &self, session: &SessionRecord, ) -> Result<(), StorageError>

Creates a session binding a device to a TLS fingerprint.

Source

pub async fn load_session( &self, session_id: &str, ) -> Result<SessionRecord, StorageError>

Loads a persisted session by identifier.

Source

pub async fn load_device( &self, device_id: &str, ) -> Result<DeviceRecord, StorageError>

Fetches device metadata by identifier.

Source

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.

Source

pub async fn upsert_device_pq_keys( &self, keys: &DevicePqKeys, ) -> Result<(), StorageError>

Upserts post-quantum key material for a device.

Source

pub async fn count_active_devices( &self, user_id: &str, ) -> Result<i64, StorageError>

Counts active devices registered for a user.

Source

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.

Source

pub async fn activate_device(&self, device_id: &str) -> Result<(), StorageError>

Marks a device as active.

Source

pub async fn deactivate_device( &self, device_id: &str, ) -> Result<(), StorageError>

Marks a device as revoked.

Source

pub async fn create_user( &self, profile: &NewUserProfile, ) -> Result<UserProfile, StorageError>

Creates a new user profile entry.

Source

pub async fn load_user( &self, user_id: &str, ) -> Result<UserProfile, StorageError>

Loads a user profile by identifier.

Source

pub async fn load_user_by_handle( &self, handle: &str, ) -> Result<UserProfile, StorageError>

Loads a user profile by handle.

Source

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.

Source

pub async fn update_user_avatar( &self, user_id: &str, avatar_url: &str, ) -> Result<(), StorageError>

Updates user avatar URL

Source

pub async fn load_user_by_federated_id( &self, handle: &str, domain: &str, ) -> Result<UserProfile, StorageError>

Loads user by handle@domain

Source

pub async fn cache_remote_user( &self, profile: &RemoteUserProfile, ) -> Result<(), StorageError>

Caches remote user profile

Source

pub async fn load_remote_user_cache( &self, user_id: &str, ) -> Result<Option<RemoteUserProfile>, StorageError>

Loads cached remote user profile

Source

pub async fn update_federation_peer_status( &self, status: &FederationPeerConnectionStatus, ) -> Result<(), StorageError>

Updates federation peer status

Source

pub async fn create_federated_friend_request( &self, request: &FederatedFriendRequest, ) -> Result<(), StorageError>

Creates federated friend request

Source

pub async fn update_federated_friend_request_status( &self, request_id: &str, status: &str, ) -> Result<(), StorageError>

Updates federated friend request status

Source

pub async fn list_federated_friend_requests( &self, user_id: &str, incoming: bool, ) -> Result<Vec<FederatedFriendRequest>, StorageError>

Lists federated friend requests for user

Source

pub async fn create_group(&self, group: &ChatGroup) -> Result<(), StorageError>

Creates a chat group entry and enrolls the owner as a member.

Source

pub async fn add_group_member( &self, member: &GroupMember, ) -> Result<(), StorageError>

Adds or updates group membership information.

Source

pub async fn remove_group_member( &self, group_id: &str, device_id: &str, ) -> Result<(), StorageError>

Removes a member from the given group.

Source

pub async fn list_group_members( &self, group_id: &str, ) -> Result<Vec<GroupMember>, StorageError>

Lists all members of a group ordered by join time.

Source

pub async fn load_group( &self, group_id: &str, ) -> Result<ChatGroup, StorageError>

Loads group metadata by identifier.

Source

pub async fn list_groups_for_device( &self, device_id: &str, ) -> Result<Vec<ChatGroup>, StorageError>

Lists groups that include the target device.

Source

pub async fn upsert_federation_peer( &self, peer: &FederationPeerRecord, ) -> Result<(), StorageError>

Upserts federation peer descriptors for S2S routing.

Source

pub async fn load_federation_peer( &self, domain: &str, ) -> Result<FederationPeerRecord, StorageError>

Loads a federation peer by domain.

Source

pub async fn list_federation_peers( &self, ) -> Result<Vec<FederationPeerRecord>, StorageError>

Enumerates all known federation peers.

Source

pub async fn set_federation_peer_status( &self, domain: &str, status: FederationPeerStatus, ) -> Result<(), StorageError>

Sets the peer status and refresh timestamp.

Source

pub async fn enqueue_relay( &self, envelope: &RelayEnvelope, ) -> Result<(), StorageError>

Schedules an encrypted relay envelope for delivery.

Source

pub async fn claim_envelopes( &self, channel_id: &str, limit: i64, ) -> Result<Vec<RelayEnvelope>, StorageError>

Claims pending relay envelopes for a channel.

Source

pub async fn enqueue_federation_outbox( &self, record: &FederationOutboxInsert<'_>, ) -> Result<(), StorageError>

Registers a federation event for outbound delivery.

Source

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.

Source

pub async fn delete_federation_outbox( &self, outbox_id: &str, ) -> Result<(), StorageError>

Removes a federation outbox entry once delivery succeeds.

Source

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.

Source

pub async fn store_inbox_offset( &self, offset: &InboxOffset, ) -> Result<(), StorageError>

Stores the last delivered envelope reference for an entity/channel pair.

Source

pub async fn read_inbox_offset( &self, entity_id: &str, channel_id: &str, ) -> Result<Option<InboxOffset>, StorageError>

Reads the stored inbox offset if present.

Source

pub async fn store_idempotency( &self, key: &IdempotencyKey, ) -> Result<bool, StorageError>

Records an idempotency key for deduplication.

Source

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

Source

pub async fn get_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>

Gets a friend request by ID

Source

pub async fn list_incoming_friend_requests( &self, user_id: &str, ) -> Result<Vec<FriendRequest>, StorageError>

Lists incoming friend requests for a user

Source

pub async fn list_outgoing_friend_requests( &self, user_id: &str, ) -> Result<Vec<FriendRequest>, StorageError>

Lists outgoing friend requests from a user

Source

pub async fn accept_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>

Accepts a friend request

Source

pub async fn reject_friend_request( &self, id: &str, ) -> Result<FriendRequest, StorageError>

Rejects a friend request

Source

pub async fn delete_friend_request(&self, id: &str) -> Result<(), StorageError>

Deletes a friend request

Source

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

Source

pub async fn publish_presence( &self, snapshot: &PresenceSnapshot, ) -> Result<(), StorageError>

Publishes local presence information into Redis.

Source

pub async fn read_presence( &self, entity: &str, ) -> Result<Option<PresenceSnapshot>, StorageError>

Reads presence state from Redis.

Source

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.

Source

pub async fn clear_route(&self, entity: &str) -> Result<(), StorageError>

Removes a routing entry from Redis.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,