Struct AsyncPgConnection

Source
pub struct AsyncPgConnection { /* private fields */ }
Available on crate feature postgres only.
Expand description

A connection to a PostgreSQL database.

Connection URLs should be in the form postgres://[user[:password]@]host/database_name

Checkout the documentation of the tokio_postgres crate for details about the format

Implementations§

Source§

impl AsyncPgConnection

Source

pub async fn try_from(conn: Client) -> ConnectionResult<Self>

Construct a new AsyncPgConnection instance from an existing tokio_postgres::Client

Source

pub fn cancel_token(&self) -> CancelToken

Constructs a cancellation token that can later be used to request cancellation of a query running on the connection associated with this client.

Trait Implementations§

Source§

impl AsyncConnection for AsyncPgConnection

Source§

async fn establish(database_url: &str) -> ConnectionResult<Self>

Establishes a new connection to the database Read more
Source§

fn is_broken(&self) -> bool

Checks if the connection is broken
Source§

impl AsyncExecute for AsyncPgConnection

A transaction on a PostgreSQL database.

Supports nested transactions.

Source§

type Stream<'conn> = Pin<Box<dyn Stream<Item = Result<PgRow, Error>> + Send + 'conn>>

The inner stream returned by AsyncConnection::load
Source§

type Row<'conn> = PgRow

The row type used by the stream returned by AsyncConnection::load
Source§

type Backend = Pg

The backend this type connects to
Source§

async fn batch_execute(&mut self, query: &str) -> QueryResult<()>

Execute multiple SQL statements within the same string. Read more
Source§

impl AsyncTransactional for AsyncPgConnection

Source§

type Transaction<'a> = AsyncPgTransaction<'a> where Self: 'a

The associated transaction type for this connection
Source§

async fn begin_transaction(&mut self) -> QueryResult<Self::Transaction<'_>>

Begins a new transaction Read more
Source§

fn transaction<'a, R, E, F>( &'a mut self, callback: F, ) -> impl Future<Output = Result<R, E>>
where F: for<'t> FnOnce(&'t mut Self::Transaction<'a>) -> Pin<Box<dyn Future<Output = Result<R, E>> + Send + 't>>, E: From<Error>,

Executes the given function inside of a database transaction Read more
Source§

impl<Changes, Output, Tab, V> UpdateAndFetchResults<Changes, Output> for AsyncPgConnection
where Output: Send, Changes: Copy + AsChangeset<Target = Tab> + Send + Identifiable<Table = Tab>, Tab: Table + FindDsl<Changes::Id>, Find<Tab, Changes::Id>: IntoUpdateTarget<Table = Tab, WhereClause = V>, UpdateStatement<Tab, V, Changes::Changeset>: AsQuery, Update<Changes, Changes>: LoadQuery<Self, Output>, V: Send, Changes::Changeset: Send, Tab::FromClause: Send,

Source§

async fn update_and_fetch(&mut self, changeset: Changes) -> QueryResult<Output>

See the traits documentation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, Conn> RunQueryDsl<Conn> for T
where T: Send,

Source§

fn execute( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<usize>> + Send
where Conn: AsyncExecute + Send, Self: ExecuteDsl<Conn>,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<U>( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<Vec<U>>> + Send
where U: Send, Conn: AsyncExecute, Self: LoadQuery<Conn, U>,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_stream<U>( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<impl Stream<Item = QueryResult<U>> + Send>> + Send
where Conn: AsyncExecute, Self: LoadQuery<Conn, U>,

Executes the given query, returning a Stream with the returned rows. Read more
Source§

fn get_result<U>( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<U>> + Send
where U: Send, Conn: AsyncExecute, Self: LoadQuery<Conn, U>,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<U>( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<Vec<U>>> + Send
where U: Send, Conn: AsyncExecute, Self: LoadQuery<Conn, U>,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<U>( self, conn: &mut Conn, ) -> impl Future<Output = QueryResult<U>> + Send
where U: Send, Conn: AsyncExecute, Self: LimitDsl, Limit<Self>: LoadQuery<Conn, U> + Send,

Attempts to load a single record. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,