Struct sql_abstractor::Postgres
source · pub struct Postgres { /* private fields */ }Expand description
Postgress implementation.
It’s a wrapper around sqlx::postgres
§Examples
It implemeents orchestrator memory abstraction, that means that could be used as:
use sql_abstractor::Postgres;
use orchestrator::prelude::*;
GenerateState!(ExerciseResult, DummyExercise);
let m = Box::new(
Postgres::clean_init("postgresql://postgres:test@localhost:5432/thesis")
.await
.unwrap(),
);
let mut o: Orchestrator<State> = Orchestrator::new(1, m);
o.run().await;Implementations§
source§impl Postgres
impl Postgres
implement some initialization
sourcepub async fn init(builder: &str) -> Result<Self, Error>
pub async fn init(builder: &str) -> Result<Self, Error>
initialize connector It could be used multiple times without loosing any data.
This is the correct way to obtain Self
sourcepub async fn clean_init(builder: &str) -> Result<Self, Error>
pub async fn clean_init(builder: &str) -> Result<Self, Error>
WARNING: THIS WILL ERASE ALL THE DATA CONTAINED IN THE DATABASE, AND THEN INIT
Trait Implementations§
source§impl<S: ExecutorGlobalState> StateMemory<S> for Postgres
impl<S: ExecutorGlobalState> StateMemory<S> for Postgres
state memory implementation
source§fn get_exercise<'life0, 'async_trait>(
&'life0 self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<(TypeId, String), Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_exercise<'life0, 'async_trait>(
&'life0 self,
name: String,
) -> Pin<Box<dyn Future<Output = Result<(TypeId, String), Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
get an exercise from memory type, source
source§fn enable_executor<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 S,
output: &'life2 S,
data: String,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn enable_executor<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
input: &'life1 S,
output: &'life2 S,
data: String,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
source§fn get_execution_plan<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<(TypeId, TypeId, String)>, Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_execution_plan<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<(TypeId, TypeId, String)>, Box<dyn StdError + Send + Sync + 'static>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§impl StatelessMemory for Postgres
impl StatelessMemory for Postgres
implementation of the StatelessMemory trait
source§fn login<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
username: &'life1 str,
password: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<User<Authenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn login<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
username: &'life1 str,
password: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<User<Authenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
tries to login the current user, returning an authenticated user instance
source§fn get_by_username<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Unauthenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_by_username<'life0, 'life1, 'async_trait>(
&'life0 self,
username: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Unauthenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
gets a user by his username
source§fn get_all_users<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<User<Unauthenticated>>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_users<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<User<Unauthenticated>>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
returns all user present in the DB.
source§fn get_authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Authenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_authenticate<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Authenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
check if the given token is valid, and if so returns the correct user
source§fn get_admin<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Admin>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_admin<'life0, 'life1, 'async_trait>(
&'life0 self,
token: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<User<Admin>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
if the token is valid, it get’s the user, and if so checks if it is an Admin
source§fn add_submission<'life0, 'async_trait>(
&'life0 self,
exercise_name: String,
source: String,
user: User<Authenticated>,
) -> Pin<Box<dyn Future<Output = Result<i64, Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_submission<'life0, 'async_trait>(
&'life0 self,
exercise_name: String,
source: String,
user: User<Authenticated>,
) -> Pin<Box<dyn Future<Output = Result<i64, Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
add submission (on success returns submission id)
source§fn add_exercise_result<'life0, 'async_trait>(
&'life0 self,
submission_id: i64,
user: User<Authenticated>,
result: ExerciseResult,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn add_exercise_result<'life0, 'async_trait>(
&'life0 self,
submission_id: i64,
user: User<Authenticated>,
result: ExerciseResult,
) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError + Send + Sync>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
add exercise result
source§fn register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
username: &'life1 str,
password: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<User<Unauthenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn register<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
username: &'life1 str,
password: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<User<Unauthenticated>, Box<dyn StdError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Auto Trait Implementations§
impl Freeze for Postgres
impl !RefUnwindSafe for Postgres
impl Send for Postgres
impl Sync for Postgres
impl Unpin for Postgres
impl !UnwindSafe for Postgres
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> 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