Skip to main content

SingleDbConnection

Struct SingleDbConnection 

Source
pub struct SingleDbConnection { /* private fields */ }
Expand description

A native database backed by a single Mutex<SqliteConnection> instead of a pool. Costs exactly one file descriptor. Chosen via the single_connection builder flag — useful for services that run many clients in one process (where a per-client pool would exhaust the OS file-descriptor limit) and do serial work per client. There is no connection reentrancy in the codebase, so a non-reentrant Mutex is safe (see the design spec).

The connection is held in an Option so that disconnect can drop it and genuinely release the underlying file descriptor (SQLite closes the fd when the connection is dropped). After a disconnect, raw_query returns PlatformStorageError::PoolNeedsConnection — the same contract as the pooled NativeDbConnection — until reconnect re-establishes it.

Trait Implementations§

Source§

impl ConnectionExt for SingleDbConnection

Source§

fn raw_query<T, F>(&self, fun: F) -> Result<T, ConnectionError>
where F: FnOnce(&mut SqliteConnection) -> Result<T, Error>, Self: Sized,

Run a scoped query against the underlying SQLite connection.
Source§

fn disconnect(&self) -> Result<(), ConnectionError>

Source§

fn reconnect(&self) -> Result<(), ConnectionError>

Source§

impl Debug for SingleDbConnection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> AggregateExpressionMethods for T

§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<C> Fetch<IdentityCache> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<PendingRemove> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredAssociationState> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredGroup> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredGroupIntent> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredGroupMessage> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredIdentity> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<StoredKeyStoreEntry> for C
where C: ConnectionExt,

Source§

impl<C> Fetch<UploadedTopic> for C
where C: ConnectionExt,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> IntoSql for T

§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<C> QueryDelivery for C
where C: ConnectionExt,

Source§

fn stream_database_id(&self) -> Result<[u8; 16], StorageError>

Read the database identity used to reject foreign or pre-restore cursors.
Source§

fn rotate_stream_database_id(&self) -> Result<[u8; 16], StorageError>

Rotate only under exclusive restore lifecycle access. Existing consumer tokens are fenced.
Source§

fn assign_delivery_sequence( &self, message_id: &[u8], ) -> Result<Option<u64>, StorageError>

Allocate within the transaction that makes a message deliverable. A duplicate keeps its number. An optimistic unpublished row has no number.
Source§

fn current_delivery_cursor(&self) -> Result<DeliveryCursor, StorageError>

Read the persistent allocator, not the maximum remaining message row.
Source§

fn acquire_delivery_owner( &self, now_ns: i64, until_ns: i64, ) -> Result<DeliveryOwner, StorageError>

Acquire the sole default-consumer lease at a supplied time; fail if one is active.
Source§

fn acquire_delivery_owner_with_clock( &self, lease_ns: i64, clock: impl FnOnce() -> i64, ) -> Result<DeliveryOwner, StorageError>

Read the clock after the writer is acquired, not before a possible lock wait.
Source§

fn renew_delivery_owner( &self, owner: DeliveryOwner, now_ns: i64, until_ns: i64, ) -> Result<(), StorageError>

An expired token cannot be renewed. The caller must acquire a new token.
Source§

fn renew_delivery_owner_with_clock( &self, owner: DeliveryOwner, lease_ns: i64, clock: impl FnOnce() -> i64, ) -> Result<(), StorageError>

Extend only the current, unexpired token using time read after the writer lock.
Source§

fn check_delivery_owner( &self, owner: DeliveryOwner, now_ns: i64, ) -> Result<(), StorageError>

Reject expired or replaced tokens before handing a message to the app.
Source§

fn check_delivery_owner_with_clock( &self, owner: DeliveryOwner, clock: impl FnOnce() -> i64, ) -> Result<(), StorageError>

Check ownership using fresh time after the database connection is available.
Source§

fn release_delivery_owner( &self, owner: DeliveryOwner, ) -> Result<(), StorageError>

Release this token only; a stale consumer cannot release its replacement.
Source§

fn delivery_message_is_retained( &self, message_id: &[u8], cursor: DeliveryCursor, now_ns: i64, ) -> Result<bool, StorageError>

A buffered candidate can expire or be deleted while its previous item is held.
Source§

fn default_delivery_messages( &self, owner: DeliveryOwner, scope: &DeliveryScope, now_ns: i64, limit: u32, ) -> Result<Vec<DeliveryMessage>, StorageError>

Read retained candidates above each group’s default position. The caller applies consent/type filters and acknowledges scanned rows by the same owner.
Source§

fn default_delivery_messages_bounded( &self, owner: DeliveryOwner, scope: &DeliveryScope, now_ns: i64, limit: u32, max_bytes: u64, ) -> Result<Vec<DeliveryMessage>, StorageError>

Bound rows and bytes before loading message bodies; this read never advances D.
Source§

fn replay_delivery_messages( &self, after: DeliveryCursor, scope: &DeliveryScope, now_ns: i64, limit: u32, ) -> Result<Vec<DeliveryMessage>, StorageError>

Explicit replay does not read or write default delivery positions.
Source§

fn replay_delivery_messages_bounded( &self, after: DeliveryCursor, scope: &DeliveryScope, now_ns: i64, limit: u32, max_bytes: u64, ) -> Result<Vec<DeliveryMessage>, StorageError>

Read a bounded retained prefix strictly after the cursor, without an owner or D writes.
Source§

fn delivery_history_snapshot( &self, scope: &DeliveryScope, now_ns: i64, limit: u32, ) -> Result<DeliverySnapshot, StorageError>

Return recent retained history and a cursor from the same database snapshot.
Source§

fn delivery_history_snapshot_bounded( &self, scope: &DeliveryScope, now_ns: i64, limit: u32, max_bytes: u64, ) -> Result<DeliverySnapshot, StorageError>

Bound history allocation while capturing its resume cursor in the same snapshot.
Source§

fn delivery_history_snapshot_filtered( &self, scope: &DeliveryScope, filter: &DeliveryFilter, now_ns: i64, limit: u32, max_bytes: u64, ) -> Result<DeliverySnapshot, StorageError>

Apply history filters before its limit, with history and cursor in one read transaction.
Source§

fn acknowledge_delivery( &self, owner: DeliveryOwner, group_id: GroupId, cursor: DeliveryCursor, now_ns: i64, ) -> Result<(), StorageError>

Acknowledge after callback return or the next iterator request, never on queue insertion. This also fences progress for rows excluded by a consent/type filter.
Source§

fn acknowledge_delivery_with_clock( &self, owner: DeliveryOwner, group_id: GroupId, cursor: DeliveryCursor, clock: impl FnOnce() -> i64, ) -> Result<(), StorageError>

Advance this group’s D only after a fresh owner check under the state writer.
Source§

impl<C> QueryIncomingEnvelope for C
where C: ConnectionExt,

Source§

fn record_welcome_discovery( &self, group_id: GroupId, welcome_cursor: Cursor, ) -> Result<(), StorageError>

Record the first successful Welcome installation inside its state transaction. Rejoin does not change discovery. Local creation and history import do not call this.
Source§

fn group_ids_discovered_through( &self, target: Cursor, ) -> Result<Vec<GroupId>, StorageError>

Groups first discovered through the fixed own-installation Welcome target. Later joins and local/imported groups cannot expand this captured discovery set.
Source§

fn record_terminal_rejection( &self, topic: &StreamTopic, sequence: Cursor, code: &'static str, ) -> Result<(), StorageError>

Keep one rejection diagnostic per topic, replacing it with a later rejection. Store a stable error code, never an input payload or a formatted error message. The caller records this inside the same state transaction that deletes the pending row.
Source§

fn read_last_rejection( &self, topic: &StreamTopic, ) -> Result<Option<TerminalRejection>, StorageError>

Read the topic’s last committed rejection code without loading envelope data.
Source§

fn admit_ordered_batch( &self, topic: &StreamTopic, after: Cursor, envelopes: &[NewIncomingEnvelope], limits: IncomingLimits, ) -> Result<AdmissionResult, StorageError>

Commit the complete ordered batch and its received position together. An overlap is safe; a gap before the source cursor is rejected. Validation, capacity, or storage failure leaves both F and pending rows unchanged.
Source§

fn topic_progress( &self, topic: &StreamTopic, ) -> Result<TopicProgress, StorageError>

Read P and F from the same row; an unseen topic starts at zero.
Source§

fn first_pending_envelope( &self, topic: &StreamTopic, ) -> Result<Option<StoredIncomingEnvelope>, StorageError>

Read the next actual ID. Missing integer IDs are not queue entries.
Source§

fn pending_envelope( &self, topic: &StreamTopic, sequence: Cursor, ) -> Result<Option<StoredIncomingEnvelope>, StorageError>

Recheck one independent welcome under the caller’s state transaction.
Source§

fn pending_states_through( &self, topic: &StreamTopic, target: Cursor, ) -> Result<Vec<PendingEnvelopeState>, StorageError>

Read actual pending IDs through the fixed target without loading ciphertext. Topic and kind admission limits bound the number of stored rows returned here.
Source§

fn complete_pending_envelope( &self, topic: &StreamTopic, sequence: Cursor, ) -> Result<bool, StorageError>

Complete only the current group or identity head. Welcomes are independent. Call this inside the state transaction that applies or rejects the envelope. Deletion and P advance commit together; an unresolved Welcome keeps its prefix open.
Source§

fn set_incoming_retry( &self, topic: &StreamTopic, sequence: Cursor, retry: &IncomingRetry, ) -> Result<bool, StorageError>

Retry metadata is written only while this work is still current.
Source§

fn ready_welcomes( &self, now_ns: i64, limit: u32, ) -> Result<Vec<StoredIncomingEnvelope>, StorageError>

Read due, unblocked Welcome rows. Production callers must also set a byte bound.
Source§

fn ready_welcomes_bounded( &self, now_ns: i64, limit: u32, max_bytes: u64, ) -> Result<Vec<StoredIncomingEnvelope>, StorageError>

Read a due prefix without loading envelope bytes above the batch budget. Permanently blocked rows require a new coordinator generation, not a timer retry.
Source§

fn blocked_welcomes_bounded( &self, topic: &StreamTopic, after: Cursor, limit: u32, max_bytes: u64, ) -> Result<Vec<StoredIncomingEnvelope>, StorageError>

Read one bounded page for a new coordinator generation to recheck unsupported work.
Source§

fn welcome_barrier_complete( &self, topic: &StreamTopic, target: Cursor, ) -> Result<bool, StorageError>

Later welcome success cannot hide an earlier unresolved welcome.
Source§

fn has_pending_welcomes(&self) -> Result<bool, StorageError>

Keep welcome private keys while any unresolved welcome can still need them.
Source§

fn install_group_anchor( &self, group_id: GroupId, anchor: Cursor, mode: JoinAnchorMode, ) -> Result<(), StorageError>

Install a validated join anchor without rewinding either durable position. The caller must check the group state and install MLS state in the same transaction.
Source§

fn pending_topic_usage( &self, kind: NetworkEntityKind, ) -> Result<Vec<PendingTopicUsage>, StorageError>

Largest queues come first; empty topics are absent and must not be paused.
Source§

impl<C> QueryPreparedEnvelope for C
where C: ConnectionExt,

Source§

fn prepared_envelopes( &self, intent_id: ID, ) -> Result<Option<Vec<u8>>, StorageError>

Read the persisted attempt. None means no attempt is currently prepared.
Source§

fn compare_and_set_prepared_envelopes( &self, intent_id: ID, expected: Option<&[u8]>, replacement: Option<&[u8]>, ) -> Result<bool, StorageError>

Replace only the exact attempt the caller read under the state writer. Late publish replies must use this check before attaching receipt metadata.
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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

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

§

fn vzip(self) -> V

§

impl<T> WindowExpressionMethods for T

§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,