pub struct Sqlx<DB: Dialect> { /* private fields */ }Expand description
The fastauth adapter over a sqlx pool. Sqlx::new(pool) infers the database from the
pool: a PgPool gives Sqlx<Postgres>, a SqlitePool gives Sqlx<Sqlite>.
Query text is rendered once per query shape and cached; values are always bind parameters. Clones share the pool and the cache.
Implementations§
Source§impl<DB: Dialect> Sqlx<DB>
impl<DB: Dialect> Sqlx<DB>
Sourcepub fn new(pool: Pool<DB>) -> Self
pub fn new(pool: Pool<DB>) -> Self
Wraps a pool. Tables keep their plain names (user, session, …).
Sourcepub fn table_prefix(self, prefix: impl Into<String>) -> Self
pub fn table_prefix(self, prefix: impl Into<String>) -> Self
Prefixes every table name: .table_prefix("fa_") stores fa_user, fa_session, …
Trait Implementations§
Source§impl<DB: Dialect> Adapter for Sqlx<DB>
impl<DB: Dialect> Adapter for Sqlx<DB>
type Tx = SqlxTx<DB>
async fn begin(&self) -> DbResult<SqlxTx<DB>>
Source§async fn introspect(&self) -> DbResult<LiveSchema>
async fn introspect(&self) -> DbResult<LiveSchema>
Reads the live schema for the migrator. Adapters without DDL return
Unsupported.Source§async fn apply(&self, plan: &MigrationPlan) -> DbResult<()>
async fn apply(&self, plan: &MigrationPlan) -> DbResult<()>
Applies a migration plan computed by the migrator.
Source§fn render_sql(&self, plan: &MigrationPlan) -> DbResult<String>
fn render_sql(&self, plan: &MigrationPlan) -> DbResult<String>
Renders a plan as SQL for
fastauth generate. Non-SQL adapters return Unsupported.Source§async fn session_with_user(
&self,
q: SessionWithUser<'_>,
) -> DbResult<Option<(Row, Row)>>
async fn session_with_user( &self, q: SessionWithUser<'_>, ) -> DbResult<Option<(Row, Row)>>
Session plus user in one call. The default does two lookups; SQL adapters override.
Source§impl<DB: Dialect> Queries for Sqlx<DB>
impl<DB: Dialect> Queries for Sqlx<DB>
async fn insert(&self, q: Insert<'_>) -> DbResult<Row>
async fn find_one(&self, q: Select<'_>) -> DbResult<Option<Row>>
async fn find_many(&self, q: Select<'_>) -> DbResult<Vec<Row>>
async fn update(&self, q: Update<'_>) -> DbResult<u64>
async fn delete(&self, q: Delete<'_>) -> DbResult<u64>
async fn count(&self, q: Select<'_>) -> DbResult<u64>
Auto Trait Implementations§
impl<DB> !RefUnwindSafe for Sqlx<DB>
impl<DB> !UnwindSafe for Sqlx<DB>
impl<DB> Forget for Sqlx<DB>
impl<DB> Freeze for Sqlx<DB>
impl<DB> Move for Sqlx<DB>
impl<DB> Send for Sqlx<DB>
impl<DB> Sync for Sqlx<DB>
impl<DB> Unpin for Sqlx<DB>
impl<DB> UnsafeUnpin for Sqlx<DB>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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 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> ⓘ
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