pub struct MemoryConnection { /* private fields */ }Expand description
A Connection that records statements and replays queued rows.
Implementations§
Source§impl MemoryConnection
impl MemoryConnection
Sourcepub fn new(dialect: Dialect) -> Self
pub fn new(dialect: Dialect) -> Self
A connection speaking dialect that returns no rows and reports one
affected row per write.
Sourcepub fn returning(self, rows: impl IntoIterator<Item = OwnedRow>) -> Self
pub fn returning(self, rows: impl IntoIterator<Item = OwnedRow>) -> Self
Queue the rows the next query should return.
Answers are consumed in order; once the queue is empty, queries return nothing.
Sourcepub fn with_outcome(self, rows_affected: u64, last_insert_id: i64) -> Self
pub fn with_outcome(self, rows_affected: u64, last_insert_id: i64) -> Self
Set the outcome every write reports.
Sourcepub fn sharded(self, family: impl Into<String>) -> Self
pub fn sharded(self, family: impl Into<String>) -> Self
Present as a sharded connector in the named family.
Sourcepub fn allocating(self, id: u64) -> Self
pub fn allocating(self, id: u64) -> Self
Mint this id whenever the repository asks for a shard-encoded key.
Sourcepub fn failing(self, message: impl Into<String>) -> Self
pub fn failing(self, message: impl Into<String>) -> Self
Make every statement fail with message.
Sourcepub fn recorded(&self) -> Vec<RecordedStatement>
pub fn recorded(&self) -> Vec<RecordedStatement>
Every statement run so far, in order.
Sourcepub fn statements(&self) -> Vec<String>
pub fn statements(&self) -> Vec<String>
The SQL of every statement run so far.
Sourcepub fn last_statement(&self) -> Option<String>
pub fn last_statement(&self) -> Option<String>
The most recent statement’s SQL.
Sourcepub fn last_route(&self) -> Option<ShardRoute>
pub fn last_route(&self) -> Option<ShardRoute>
The most recent statement’s shard route.
Sourcepub fn statement_count(&self) -> usize
pub fn statement_count(&self) -> usize
How many statements have run.
Trait Implementations§
Source§impl Connection for MemoryConnection
impl Connection for MemoryConnection
Source§fn shard_family(&self) -> Option<String>
fn shard_family(&self) -> Option<String>
The shard family this connector routes within, or
None for a single
database.Source§fn allocate_id(&self, _shard_key: u64) -> Option<u64>
fn allocate_id(&self, _shard_key: u64) -> Option<u64>
Mint a shard-encoded primary key for a row owned by
shard_key.Source§fn fetch<'a>(
&'a self,
route: ShardRoute,
sql: &'a str,
params: Vec<Value>,
_columns: Vec<ColumnRequest>,
) -> BoxFuture<'a, Result<Vec<OwnedRow>>>
fn fetch<'a>( &'a self, route: ShardRoute, sql: &'a str, params: Vec<Value>, _columns: Vec<ColumnRequest>, ) -> BoxFuture<'a, Result<Vec<OwnedRow>>>
Run a query, copying the named columns out of each row. Read more
Source§impl Debug for MemoryConnection
impl Debug for MemoryConnection
Source§impl Default for MemoryConnection
impl Default for MemoryConnection
Source§fn default() -> MemoryConnection
fn default() -> MemoryConnection
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for MemoryConnection
impl RefUnwindSafe for MemoryConnection
impl Send for MemoryConnection
impl Sync for MemoryConnection
impl Unpin for MemoryConnection
impl UnsafeUnpin for MemoryConnection
impl UnwindSafe for MemoryConnection
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
Mutably borrows from an owned value. Read more
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.