pub struct PostgresUserStore { /* private fields */ }
Expand description
PostgreSQL
user store with connection pooling and migrations.
Implementations§
Source§impl PostgresUserStore
impl PostgresUserStore
Sourcepub async fn new(database_url: &str) -> Result<Self, Error>
pub async fn new(database_url: &str) -> Result<Self, Error>
Create a new PostgreSQL
user store with default configuration.
§Arguments
database_url
-PostgreSQL
connection string
§Errors
Err(sqlx::Error::Configuration(format!("Migration failed: {e}")))
- If the migration fails
§Returns
Ok(Self)
- If the store is created successfully
§Examples
use actix_passport::user_store::stores::postgres::PostgresUserStore;
let store = PostgresUserStore::new("postgres://user:pass@localhost/db").await?;
Sourcepub async fn with_config(
database_url: &str,
config: PostgresConfig,
) -> Result<Self, Error>
pub async fn with_config( database_url: &str, config: PostgresConfig, ) -> Result<Self, Error>
Create a new PostgreSQL
user store with custom configuration.
§Arguments
database_url
-PostgreSQL
connection stringconfig
- Store configuration options
§Errors
Err(sqlx::Error::Configuration(format!("Migration failed: {e}")))
- If the migration fails
§Returns
Ok(Self)
- If the store is created successfully
Trait Implementations§
Source§impl Clone for PostgresUserStore
impl Clone for PostgresUserStore
Source§fn clone(&self) -> PostgresUserStore
fn clone(&self) -> PostgresUserStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl UserStore for PostgresUserStore
impl UserStore for PostgresUserStore
Source§fn find_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_id<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Finds a user by their unique ID. Read more
Source§fn find_by_email<'life0, 'life1, 'async_trait>(
&'life0 self,
email: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_email<'life0, 'life1, 'async_trait>(
&'life0 self,
email: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Finds a user by their email address. Read more
Source§fn find_by_username<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn find_by_username<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str,
) -> Pin<Box<dyn Future<Output = AuthResult<Option<AuthUser>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Finds a user by their username. Read more
Source§fn create_user<'life0, 'async_trait>(
&'life0 self,
user: AuthUser,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthUser>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_user<'life0, 'async_trait>(
&'life0 self,
user: AuthUser,
) -> Pin<Box<dyn Future<Output = AuthResult<AuthUser>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Creates a new user in the store. Read more
Auto Trait Implementations§
impl Freeze for PostgresUserStore
impl !RefUnwindSafe for PostgresUserStore
impl Send for PostgresUserStore
impl Sync for PostgresUserStore
impl Unpin for PostgresUserStore
impl !UnwindSafe for PostgresUserStore
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