pub struct PostgresStorage<S> { /* private fields */ }Available on crate features
postgres-storage-nativetls or postgres-storage-rustls only.Expand description
A persistent dialogue storage based on PostgreSQL
Implementations§
Source§impl<S> PostgresStorage<S>
impl<S> PostgresStorage<S>
Sourcepub async fn open(
database_url: &str,
max_connections: u32,
serializer: S,
) -> Result<Arc<Self>, PostgresStorageError<Infallible>>
pub async fn open( database_url: &str, max_connections: u32, serializer: S, ) -> Result<Arc<Self>, PostgresStorageError<Infallible>>
Opens a connection pool to the Postgres database and creates the table for storing dialogues.
Parameters:
- database_url: full url to the postgres database, for example
"postgres://postgres:password@localhost/test") - max_connections: number of connections in creating connection pool. Be mindful of the connection limits for your database, each connection established with the Postgres creates a new process on the server side
- serializer: what
Serializerwill be used to encode the dialogue data. Available ones are:Json,Bincode,Cbor
Trait Implementations§
Source§impl<S, D> Storage<D> for PostgresStorage<S>where
S: Send + Sync + Serializer<D> + 'static,
D: Send + Serialize + DeserializeOwned + 'static,
<S as Serializer<D>>::Error: Debug + Display,
impl<S, D> Storage<D> for PostgresStorage<S>where
S: Send + Sync + Serializer<D> + 'static,
D: Send + Serialize + DeserializeOwned + 'static,
<S as Serializer<D>>::Error: Debug + Display,
type Error = PostgresStorageError<<S as Serializer<D>>::Error>
Source§fn remove_dialogue(
self: Arc<Self>,
key: DialogueKey,
) -> BoxFuture<'static, Result<(), Self::Error>>where
D: Send + 'static,
fn remove_dialogue(
self: Arc<Self>,
key: DialogueKey,
) -> BoxFuture<'static, Result<(), Self::Error>>where
D: Send + 'static,
Removes a dialogue indexed by
key. Read moreSource§fn update_dialogue(
self: Arc<Self>,
key: DialogueKey,
dialogue: D,
) -> BoxFuture<'static, Result<(), Self::Error>>where
D: Send + 'static,
fn update_dialogue(
self: Arc<Self>,
key: DialogueKey,
dialogue: D,
) -> BoxFuture<'static, Result<(), Self::Error>>where
D: Send + 'static,
Updates a dialogue indexed by
key with dialogue.Source§fn get_dialogue(
self: Arc<Self>,
key: DialogueKey,
) -> BoxFuture<'static, Result<Option<D>, Self::Error>>
fn get_dialogue( self: Arc<Self>, key: DialogueKey, ) -> BoxFuture<'static, Result<Option<D>, Self::Error>>
Returns the dialogue indexed by
key.Source§fn get_or_insert_dialogue(
self: Arc<Self>,
key: DialogueKey,
default: fn() -> D,
reset_incompatible: bool,
) -> BoxFuture<'static, Result<D, Self::Error>>
fn get_or_insert_dialogue( self: Arc<Self>, key: DialogueKey, default: fn() -> D, reset_incompatible: bool, ) -> BoxFuture<'static, Result<D, Self::Error>>
Returns the stored dialogue or initializes it with
default if absent.
Implementations must not overwrite a concurrently inserted dialogue.
When reset_incompatible is true, implementations may also replace a
state that fails to deserialize, but must not ignore other errors or
overwrite a concurrent update.Source§fn erase(self: Arc<Self>) -> Arc<ErasedStorage<D>> ⓘ
fn erase(self: Arc<Self>) -> Arc<ErasedStorage<D>> ⓘ
Erases
Self::Error to std::error::Error.Auto Trait Implementations§
impl<S> !RefUnwindSafe for PostgresStorage<S>
impl<S> !UnwindSafe for PostgresStorage<S>
impl<S> Forget for PostgresStorage<S>
impl<S> Freeze for PostgresStorage<S>
impl<S> Move for PostgresStorage<S>
impl<S> Send for PostgresStorage<S>
impl<S> Sync for PostgresStorage<S>
impl<S> Unpin for PostgresStorage<S>
impl<S> UnsafeUnpin for PostgresStorage<S>where
*const ArcInner<PoolInner<Postgres>> is !null: UnsafeUnpin,
PhantomData<ArcInner<PoolInner<Postgres>>>: UnsafeUnpin,
S: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Erasable for T
impl<T> Erasable for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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