pub struct MockDbClient { /* private fields */ }
Expand description
Provides high-level operations for data management.
This is usually manifested by database::DbClientImpl
Implementations§
source§impl MockDbClient
impl MockDbClient
sourcepub fn checkpoint(&mut self)
pub fn checkpoint(&mut self)
Validate that all current expectations for all methods have been satisfied, and discard them.
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new mock object with no expectations.
This method will not be generated if the real struct
already has a new
method. However, it will be
generated if the struct implements a trait with a new
method. The trait’s new
method can still be called
like <MockX as TraitY>::new
source§impl MockDbClient
impl MockDbClient
sourcepub fn expect_add_user(&mut self) -> &mut Expectation
pub fn expect_add_user(&mut self) -> &mut Expectation
Create an Expectation
for mocking the add_user
method
sourcepub fn expect_update_user(&mut self) -> &mut Expectation
pub fn expect_update_user(&mut self) -> &mut Expectation
Create an Expectation
for mocking the update_user
method
sourcepub fn expect_get_user(&mut self) -> &mut Expectation
pub fn expect_get_user(&mut self) -> &mut Expectation
Create an Expectation
for mocking the get_user
method
sourcepub fn expect_remove_user(&mut self) -> &mut Expectation
pub fn expect_remove_user(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_user
method
sourcepub fn expect_add_channel(&mut self) -> &mut Expectation
pub fn expect_add_channel(&mut self) -> &mut Expectation
Create an Expectation
for mocking the add_channel
method
sourcepub fn expect_add_channels(&mut self) -> &mut Expectation
pub fn expect_add_channels(&mut self) -> &mut Expectation
Create an Expectation
for mocking the add_channels
method
sourcepub fn expect_get_channels(&mut self) -> &mut Expectation
pub fn expect_get_channels(&mut self) -> &mut Expectation
Create an Expectation
for mocking the get_channels
method
sourcepub fn expect_remove_channel(&mut self) -> &mut Expectation
pub fn expect_remove_channel(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_channel
method
sourcepub fn expect_remove_node_id(&mut self) -> &mut Expectation
pub fn expect_remove_node_id(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_node_id
method
sourcepub fn expect_save_message(&mut self) -> &mut Expectation
pub fn expect_save_message(&mut self) -> &mut Expectation
Create an Expectation
for mocking the save_message
method
sourcepub fn expect_save_messages(&mut self) -> &mut Expectation
pub fn expect_save_messages(&mut self) -> &mut Expectation
Create an Expectation
for mocking the save_messages
method
sourcepub fn expect_fetch_topic_messages(&mut self) -> &mut Expectation
pub fn expect_fetch_topic_messages(&mut self) -> &mut Expectation
Create an Expectation
for mocking the fetch_topic_messages
method
sourcepub fn expect_fetch_timestamp_messages(&mut self) -> &mut Expectation
pub fn expect_fetch_timestamp_messages(&mut self) -> &mut Expectation
Create an Expectation
for mocking the fetch_timestamp_messages
method
sourcepub fn expect_increment_storage(&mut self) -> &mut Expectation
pub fn expect_increment_storage(&mut self) -> &mut Expectation
Create an Expectation
for mocking the increment_storage
method
sourcepub fn expect_remove_message(&mut self) -> &mut Expectation
pub fn expect_remove_message(&mut self) -> &mut Expectation
Create an Expectation
for mocking the remove_message
method
sourcepub fn expect_router_table_exists(&mut self) -> &mut Expectation
pub fn expect_router_table_exists(&mut self) -> &mut Expectation
Create an Expectation
for mocking the router_table_exists
method
sourcepub fn expect_message_table_exists(&mut self) -> &mut Expectation
pub fn expect_message_table_exists(&mut self) -> &mut Expectation
Create an Expectation
for mocking the message_table_exists
method
sourcepub fn expect_health_check(&mut self) -> &mut Expectation
pub fn expect_health_check(&mut self) -> &mut Expectation
Create an Expectation
for mocking the health_check
method
sourcepub fn expect_name(&mut self) -> &mut Expectation
pub fn expect_name(&mut self) -> &mut Expectation
Create an Expectation
for mocking the name
method
sourcepub fn expect_pool_status(&mut self) -> &mut Expectation
pub fn expect_pool_status(&mut self) -> &mut Expectation
Create an Expectation
for mocking the pool_status
method
sourcepub fn expect_box_clone(&mut self) -> &mut Expectation
pub fn expect_box_clone(&mut self) -> &mut Expectation
Create an Expectation
for mocking the box_clone
method
source§impl MockDbClient
impl MockDbClient
sourcepub fn into_boxed_arc(self) -> Box<Arc<Self>>
pub fn into_boxed_arc(self) -> Box<Arc<Self>>
Convert into a type which can be used in place of Box<dyn DbClient>
.
Arc is used so that the mock can be cloned. Box is used so it can be
easily cast to Box<dyn DbClient>
.
Trait Implementations§
source§impl DbClient for MockDbClient
impl DbClient for MockDbClient
Provides high-level operations for data management.
This is usually manifested by database::DbClientImpl
source§fn add_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 User,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 User,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add a new user to the database. An error will occur if the user already exists.
source§fn update_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 mut User,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_user<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 mut User,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update a user in the database. Returns whether the update occurred. The
update will not occur if the user does not already exist, has a
different router type, or has a newer connected_at
timestamp.
source§fn get_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<Option<User>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<Option<User>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a user from the database
source§fn remove_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn remove_user<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a user from the router table
source§fn add_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn add_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Add a channel to a user
source§fn add_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channels: HashSet<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn add_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channels: HashSet<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Add a batch of channels to a user
source§fn get_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<HashSet<Uuid>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_channels<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<HashSet<Uuid>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get the set of channel IDs for a user
source§fn remove_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_channel<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
channel_id: &'life2 Uuid,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Remove a channel from a user. Returns if the removed channel did exist.
source§fn remove_node_id<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
node_id: &'life2 str,
connected_at: u64,
version: &'life3 Option<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn remove_node_id<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
node_id: &'life2 str,
connected_at: u64,
version: &'life3 Option<Uuid>,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Remove the node ID from a user in the router table. Returns whether the
removal occurred. The node ID will only be removed if connected_at
matches up with the item’s connected_at
.
source§fn save_message<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
message: Notification,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_message<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
message: Notification,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Save a message to the message table
source§fn save_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
messages: Vec<Notification>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn save_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
messages: Vec<Notification>,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Save multiple messages to the message table
source§fn fetch_topic_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_topic_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch stored messages for a user
source§fn fetch_timestamp_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: Option<u64>,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn fetch_timestamp_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: Option<u64>,
limit: usize,
) -> Pin<Box<dyn Future<Output = DbResult<FetchMessageResponse>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch stored messages later than a given
source§fn increment_storage<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: u64,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment_storage<'life0, 'life1, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
timestamp: u64,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update the last read timestamp for a user
source§fn remove_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
sort_key: &'life2 str,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remove_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
uaid: &'life1 Uuid,
sort_key: &'life2 str,
) -> Pin<Box<dyn Future<Output = DbResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete a notification
source§fn router_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn router_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the router table exists
source§fn message_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn message_table_exists<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if the message table exists
source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DbResult<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Perform the health check on this data store
source§fn name(&self) -> String
fn name(&self) -> String
Provide the module name. This was added for simple dual mode testing (legacy), but may be useful in other situations.
source§fn pool_status(&self) -> Option<Status>
fn pool_status(&self) -> Option<Status>
Return the current deadpool Status (if using deadpool)