ydb_unofficial/sqlx/
database.rs

1use sqlx_core::arguments::IntoArguments;
2use sqlx_core::arguments::Arguments;
3use sqlx_core::database::{Database, HasArguments, HasStatement, HasValueRef};
4use ydb_grpc_bindings::generated::ydb;
5
6use super::prelude::*;
7
8pub type YdbArgumentBuffer = std::collections::HashMap<String, ydb::TypedValue>;
9
10#[derive(Debug, Clone, Copy, Default)]
11pub struct Ydb;
12
13impl Database for Ydb {
14    type Connection = YdbConnection;
15
16    type TransactionManager = YdbTransactionManager;
17
18    type Row = YdbRow;
19
20    type QueryResult = YdbQueryResult;
21
22    type Column = YdbColumn;
23
24    type TypeInfo = YdbTypeInfo;
25
26    type Value = YdbValue;
27
28    const NAME: &'static str = "Ydb";
29
30    const URL_SCHEMES: &'static [&'static str] = &["ydb", "ydbs"];
31}
32
33impl<'a> HasArguments<'a> for Ydb {
34    type Database = Self;
35
36    type Arguments = YdbArguments;
37
38    type ArgumentBuffer=YdbArgumentBuffer;
39}
40
41#[derive(Debug, Default, Clone)]
42pub struct YdbArguments(pub(crate) YdbArgumentBuffer);
43
44impl<'q> Arguments<'q> for YdbArguments {
45    type Database = Ydb;
46
47    fn reserve(&mut self, _additional: usize, _size: usize) {
48        //TODO: implement me
49    }
50
51    fn add<T>(&mut self, value: T)
52    where T: 'q + Send + sqlx_core::encode::Encode<'q, Ydb> + sqlx_core::types::Type<Ydb> {
53        let _ = value.encode(&mut self.0);
54    }
55}
56
57impl<'a> IntoArguments<'a, Ydb> for &YdbArguments {
58    fn into_arguments(self) -> YdbArguments {
59        self.clone()
60    }
61}
62
63impl IntoArguments<'_, Ydb> for YdbArguments {
64    fn into_arguments(self) -> YdbArguments {
65        self
66    }
67}
68
69impl <'a> HasStatement<'a> for Ydb {
70    type Database = Self;
71
72    type Statement = YdbStatement;
73}
74
75impl <'a> HasValueRef<'a> for Ydb {
76    type Database = Self;
77    type ValueRef = YdbValueRef<'a>;
78}