Trait diesel::backend::Backend

source ·
pub trait Backend{
    type QueryBuilder: QueryBuilder<Self>;
}
Expand description

A database backend

This trait represents the concept of a backend (e.g. “MySQL” vs “SQLite”). It is separate from a Connection to that backend. One backend may have multiple concrete connection implementations.

§Implementing a custom backend

Implementing a custom backend requires enabling the i-implement-a-third-party-backend-and-opt-into-breaking-changes crate feature to get access to all necessary type and trait implementations.

Implementations of this trait should not assume details about how the connection is implemented. For example, the Pg backend does not assume that libpq is being used. Implementations of this trait can and should care about details of the wire protocol used to communicated with the database.

Implementing support for a new backend is a complex topic and depends on the details how the newly implemented backend may communicate with diesel. As of this we cannot provide concrete examples here and only present a general outline of the required steps. Existing backend implementations provide a good starting point to see how certain things are solve for other backend implementations.

Types implementing Backend should generally be zero sized structs.

To implement the Backend trait you need to:

Additionally to the listed required trait bounds you may want to implement DieselReserveSpecialization to opt in existing wild card QueryFragment impls for large parts of the dsl.

Required Associated Types§

source

type QueryBuilder: QueryBuilder<Self>

The concrete QueryBuilder implementation for this backend.

Object Safety§

This trait is not object safe.

Implementors§