pub trait DbAdapter: Send + Sync {
Show 14 methods
// Required methods
fn id(&self) -> &str;
fn create<'a>(
&'a self,
query: Create,
) -> Pin<Box<dyn Future<Output = Result<IndexMap<String, DbValue>, RustAuthError>> + Send + 'a>>;
fn find_one<'a>(
&'a self,
query: FindOne,
) -> Pin<Box<dyn Future<Output = Result<Option<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>;
fn find_many<'a>(
&'a self,
query: FindMany,
) -> Pin<Box<dyn Future<Output = Result<Vec<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>;
fn count<'a>(
&'a self,
query: Count,
) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>;
fn update<'a>(
&'a self,
query: Update,
) -> Pin<Box<dyn Future<Output = Result<Option<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>;
fn update_many<'a>(
&'a self,
query: UpdateMany,
) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>;
fn delete<'a>(
&'a self,
query: Delete,
) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>;
fn delete_many<'a>(
&'a self,
query: DeleteMany,
) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>;
fn transaction<'a>(
&'a self,
callback: Box<dyn for<'tx> FnOnce(Box<dyn DbAdapter + 'tx>) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'tx>> + Send + 'a>,
) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>;
// Provided methods
fn capabilities(&self) -> AdapterCapabilities { ... }
fn create_schema<'a>(
&'a self,
_schema: &'a DbSchema,
_file: Option<&'a str>,
) -> Pin<Box<dyn Future<Output = Result<Option<SchemaCreation>, RustAuthError>> + Send + 'a>> { ... }
fn run_migrations<'a>(
&'a self,
_schema: &'a DbSchema,
) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>> { ... }
fn run_plugin_migrations<'a>(
&'a self,
_migrations: &'a [PluginMigration],
) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>> { ... }
}Expand description
Async database adapter contract used by core authentication behavior.
Concrete database integrations should live outside rustauth-core and
implement this trait without forcing their driver or ORM dependencies into
the core crate.
Required Methods§
fn id(&self) -> &str
fn create<'a>( &'a self, query: Create, ) -> Pin<Box<dyn Future<Output = Result<IndexMap<String, DbValue>, RustAuthError>> + Send + 'a>>
fn find_one<'a>( &'a self, query: FindOne, ) -> Pin<Box<dyn Future<Output = Result<Option<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>
fn find_many<'a>( &'a self, query: FindMany, ) -> Pin<Box<dyn Future<Output = Result<Vec<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>
fn count<'a>( &'a self, query: Count, ) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>
fn update<'a>( &'a self, query: Update, ) -> Pin<Box<dyn Future<Output = Result<Option<IndexMap<String, DbValue>>, RustAuthError>> + Send + 'a>>
fn update_many<'a>( &'a self, query: UpdateMany, ) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>
fn delete<'a>( &'a self, query: Delete, ) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>
fn delete_many<'a>( &'a self, query: DeleteMany, ) -> Pin<Box<dyn Future<Output = Result<u64, RustAuthError>> + Send + 'a>>
fn transaction<'a>( &'a self, callback: Box<dyn for<'tx> FnOnce(Box<dyn DbAdapter + 'tx>) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'tx>> + Send + 'a>, ) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>
Provided Methods§
fn capabilities(&self) -> AdapterCapabilities
fn create_schema<'a>( &'a self, _schema: &'a DbSchema, _file: Option<&'a str>, ) -> Pin<Box<dyn Future<Output = Result<Option<SchemaCreation>, RustAuthError>> + Send + 'a>>
fn run_migrations<'a>( &'a self, _schema: &'a DbSchema, ) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>
fn run_plugin_migrations<'a>( &'a self, _migrations: &'a [PluginMigration], ) -> Pin<Box<dyn Future<Output = Result<(), RustAuthError>> + Send + 'a>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".