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:
AsyncMysqlConnection(enabled by themysqlfeature, currently not supported)AsyncPgConnection(enabled by thepostgresfeature)
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. - mysql
mysql - Provides types and functions related to working with MySQL
- pg
postgres - Provides types and functions related to working with PostgreSQL
- pooled_
connection deadpoolorbb8 - This module contains support using benzin with various async rust connection pooling solutions
Structs§
- Async
Mysql Connection mysql - A connection to a MySQL database.
- Async
PgConnection postgres - A connection to a PostgreSQL database.
- Test
Connection - A test connection that can be used to test the diesel API
Traits§
- Async
Connection - An async connection to a database
- Async
Execute - A basic trait for executing queries
- Async
Transaction - An async transaction
- Async
Transactional - An async transactional entity
- Execute
Dsl - The
executemethod - Load
Query - The
loadmethod - RunQuery
Dsl - Methods used to execute queries.
- Save
Changes Dsl - Sugar for types which implement both
AsChangesetandIdentifiable - Update
AndFetch Results - A trait defining how to update a record and fetch the updated entry on a certain backend.