Crate benzin

Source
Expand description

Benzin provides async variants of diesel related query functionality

benzin is a rework of diesel_async with proper transaction handling (is does not leave dangling transactions in case of a cancelled future)

benzin is an extension to diesel itself. It is designed to be used together with the main diesel crate. It only provides async variants of core diesel traits, that perform actual io-work.

In addition to these core traits 2 fully async connection implementations are provided by benzin:

Ordinary usage of benzin assumes that you just replace the corresponding sync trait method calls and connections with their async counterparts.

use diesel::prelude::*;
use benzin::{RunQueryDsl, AsyncConnection};

diesel::table! {
   users(id) {
       id -> Integer,
       name -> Text,
   }
}

use crate::users::dsl::*;


let data = users
    // use ordinary diesel query dsl here
    .filter(id.gt(0))
    // execute the query via the provided
    // async variant of `benzin::RunQueryDsl`
    .load::<(i32, String)>(&mut connection)
    .await?;
let expected_data = vec![
    (1, String::from("Sean")),
    (2, String::from("Tess")),
];
assert_eq!(expected_data, data);

Modules§

methods
The traits used by QueryDsl.
mysqlmysql
Provides types and functions related to working with MySQL
pgpostgres
Provides types and functions related to working with PostgreSQL
pooled_connectiondeadpool or bb8
This module contains support using benzin with various async rust connection pooling solutions

Structs§

AsyncMysqlConnectionmysql
A connection to a MySQL database.
AsyncPgConnectionpostgres
A connection to a PostgreSQL database.
TestConnection
A test connection that can be used to test the diesel API

Traits§

AsyncConnection
An async connection to a database
AsyncExecute
A basic trait for executing queries
AsyncTransaction
An async transaction
AsyncTransactional
An async transactional entity
ExecuteDsl
The execute method
LoadQuery
The load method
RunQueryDsl
Methods used to execute queries.
SaveChangesDsl
Sugar for types which implement both AsChangeset and Identifiable
UpdateAndFetchResults
A trait defining how to update a record and fetch the updated entry on a certain backend.