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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std::sync::Arc;
use oracle::sql_type::OracleType;
use rbdc::db::{Row, MetaData};
use rbs::Value;
use crate::decode::Decode;
pub mod decode;
pub mod driver;
pub mod encode;
pub mod options;
pub mod connection;
#[derive(Debug,Clone)]
pub struct OracleColumn{
pub name:String,
pub column_type:OracleType
}
#[derive(Debug)]
pub struct OracleMetaData(pub Arc<Vec<OracleColumn>>);
impl MetaData for OracleMetaData {
fn column_len(&self) -> usize {
self.0.len()
}
fn column_name(&self, i: usize) -> String {
self.0[i].name.to_string()
}
fn column_type(&self, i: usize) -> String {
format!("{:?}", self.0[i].column_type)
}
}
#[derive(Debug)]
pub struct OracleData{
pub str:Option<String>,
pub column_type:OracleType
}
#[derive(Debug)]
pub struct OracleRow {
pub columns: Arc<Vec<OracleColumn>>,
pub datas: Vec<OracleData>,
}
impl Row for OracleRow {
fn meta_data(&self) -> Box<dyn MetaData> {
Box::new(OracleMetaData(self.columns.clone()))
}
fn get(&mut self, i: usize) -> Result<Value, rbdc::Error> {
Value::decode(
&self.datas[i],
)
}
}