forked from transact-rs/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.rs
More file actions
45 lines (36 loc) · 1.49 KB
/
Copy pathdatabase.rs
File metadata and controls
45 lines (36 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::fmt::Debug;
use std::hash::Hash;
use crate::{Column, QueryResult, RawValue, Row, TypeInfo};
/// A database driver.
///
/// Represents a family of traits for interacting with a database. This is
/// separate from [`Connection`][crate::Connection]. One database driver may
/// have multiple concrete `Connection` implementations.
///
pub trait Database:
'static + Sized + Debug + for<'x> HasOutput<'x> + for<'r> HasRawValue<'r, Database = Self>
{
/// The concrete [`Column`] implementation for this database.
type Column: Column<Database = Self>;
/// The concrete [`Row`] implementation for this database.
type Row: Row<Database = Self>;
/// The concrete [`QueryResult`] implementation for this database.
type QueryResult: QueryResult;
/// The concrete [`TypeInfo`] implementation for this database.
type TypeInfo: TypeInfo<Database = Self>;
/// The concrete [`TypeId`] implementation for this database.
type TypeId: 'static + PartialEq + Hash + Clone + Copy + Send + Sync;
}
/// Associates [`Database`] with an `Output` of a generic lifetime.
// 'x: single execution
pub trait HasOutput<'x> {
/// The concrete type to hold the output for [`Encode`] for this database.
type Output;
}
/// Associates [`Database`] with a `RawValue` of a generic lifetime.
// 'r: row
pub trait HasRawValue<'r> {
type Database: Database;
/// The concrete type to hold the input for [`Decode`] for this database.
type RawValue: RawValue<'r, Database = Self::Database>;
}