pub struct SqlxBackend { /* private fields */ }Expand description
SQL-based backend implementing BackendImpl using sqlx.
This backend supports both SQLite and PostgreSQL through sqlx’s AnyPool.
§Thread Safety
SqlxBackend is Send + Sync as required by BackendImpl. The underlying
sqlx pool handles connection pooling and thread safety.
§Test Isolation
For PostgreSQL, each backend instance can use its own schema for test isolation.
Use connect_postgres_isolated() to create an isolated backend for testing.
Implementations§
Source§impl SqlxBackend
impl SqlxBackend
Source§impl SqlxBackend
impl SqlxBackend
Sourcepub async fn open_sqlite<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn open_sqlite<P: AsRef<Path>>(path: P) -> Result<Self>
Open a SQLite database at the given path.
Creates the database file and schema if they don’t exist.
§Arguments
path- Path to the SQLite database file
§Example
use eidetica::backend::database::sql::SqlxBackend;
#[tokio::main]
async fn main() {
let backend = SqlxBackend::open_sqlite("my_database.db").await.unwrap();
}Sourcepub async fn connect_sqlite(url: &str) -> Result<Self>
pub async fn connect_sqlite(url: &str) -> Result<Self>
Connect to a SQLite database using a connection URL.
§Arguments
url- SQLite connection URL (e.g., “sqlite:./my.db”)
Sourcepub async fn sqlite_in_memory() -> Result<Self>
pub async fn sqlite_in_memory() -> Result<Self>
Source§impl SqlxBackend
impl SqlxBackend
Sourcepub async fn connect_postgres(url: &str) -> Result<Self>
pub async fn connect_postgres(url: &str) -> Result<Self>
Connect to a PostgreSQL database using a connection URL.
This connects to the default (public) schema. For test isolation,
use connect_postgres_isolated() instead.
§Arguments
url- PostgreSQL connection URL (e.g., “postgres://user:pass@localhost/dbname”)
§Example
use eidetica::backend::database::sql::SqlxBackend;
let backend = SqlxBackend::connect_postgres("postgres://localhost/eidetica").await.unwrap();Sourcepub async fn connect_postgres_isolated(url: &str) -> Result<Self>
pub async fn connect_postgres_isolated(url: &str) -> Result<Self>
Connect to a PostgreSQL database with test isolation.
Creates a unique schema for this backend instance, ensuring tests don’t interfere with each other when run in parallel.
§Arguments
url- PostgreSQL connection URL (e.g., “postgres://user:pass@localhost/dbname”)
§Example
use eidetica::backend::database::sql::SqlxBackend;
let backend = SqlxBackend::connect_postgres_isolated("postgres://localhost/eidetica").await.unwrap();
// This backend uses its own isolated schemaTrait Implementations§
Source§impl BackendImpl for SqlxBackend
impl BackendImpl for SqlxBackend
Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Entry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Entry>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_verification_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<VerificationStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_verification_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<VerificationStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn put<'life0, 'async_trait>(
&'life0 self,
verification_status: VerificationStatus,
entry: Entry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn put<'life0, 'async_trait>(
&'life0 self,
verification_status: VerificationStatus,
entry: Entry,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn update_verification_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
verification_status: VerificationStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_verification_status<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 ID,
verification_status: VerificationStatus,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_entries_by_verification_status<'life0, 'async_trait>(
&'life0 self,
status: VerificationStatus,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_entries_by_verification_status<'life0, 'async_trait>(
&'life0 self,
status: VerificationStatus,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_tips<'life0, 'life1, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tips<'life0, 'life1, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_store_tips<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_store_tips<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn get_store_tips_up_to_entries<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
main_entries: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn get_store_tips_up_to_entries<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
main_entries: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn all_roots<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn all_roots<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn find_merge_base<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
entry_ids: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<ID>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn find_merge_base<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
entry_ids: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<ID>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn collect_root_to_target<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
target_entry: &'life3 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn collect_root_to_target<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
target_entry: &'life3 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn as_any(&self) -> &dyn Any
fn as_any(&self) -> &dyn Any
Any type. Read moreSource§fn get_tree<'life0, 'life1, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_tree<'life0, 'life1, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn get_tree_from_tips<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
tips: &'life2 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_tree_from_tips<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
tips: &'life2 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn get_store_from_tips<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
tips: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn get_store_from_tips<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree: &'life1 ID,
store: &'life2 str,
tips: &'life3 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<Entry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn get_cached_crdt_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_cached_crdt_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 ID,
store: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn cache_crdt_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 ID,
store: &'life2 str,
state: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn cache_crdt_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
entry_id: &'life1 ID,
store: &'life2 str,
state: String,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn clear_crdt_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_crdt_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_sorted_store_parents<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree_id: &'life1 ID,
entry_id: &'life2 ID,
store: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn get_sorted_store_parents<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
tree_id: &'life1 ID,
entry_id: &'life2 ID,
store: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn get_path_from_to<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tree_id: &'life1 ID,
store: &'life2 str,
from_id: &'life3 ID,
to_ids: &'life4 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn get_path_from_to<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
tree_id: &'life1 ID,
store: &'life2 str,
from_id: &'life3 ID,
to_ids: &'life4 [ID],
) -> Pin<Box<dyn Future<Output = Result<Vec<ID>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§fn get_instance_metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<InstanceMetadata>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_instance_metadata<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Option<InstanceMetadata>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn set_instance_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 InstanceMetadata,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_instance_metadata<'life0, 'life1, 'async_trait>(
&'life0 self,
metadata: &'life1 InstanceMetadata,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Auto Trait Implementations§
impl Freeze for SqlxBackend
impl !RefUnwindSafe for SqlxBackend
impl Send for SqlxBackend
impl Sync for SqlxBackend
impl Unpin for SqlxBackend
impl !UnwindSafe for SqlxBackend
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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