mostly working now
This commit is contained in:
parent
a581d0c5b8
commit
5eac797a93
20 changed files with 675 additions and 454 deletions
|
@ -15,3 +15,4 @@ thread_local = "1.1.4"
|
|||
lazy_static = "1.4"
|
||||
parking_lot = "0.11.1"
|
||||
futures = "0.3"
|
||||
uuid = { version = "1.1.2", features = ["v4"] }
|
|
@ -60,6 +60,14 @@ impl<const C: usize> Bind for &[u8; C] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<const C: usize> Column for [u8; C] {
|
||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||
let bytes_slice = statement.column_blob(start_index)?;
|
||||
let array = bytes_slice.try_into()?;
|
||||
Ok((array, start_index + 1))
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for Vec<u8> {}
|
||||
impl Bind for Vec<u8> {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
|
@ -236,8 +244,7 @@ impl<T: Bind + StaticColumnCount> Bind for Option<T> {
|
|||
if let Some(this) = self {
|
||||
this.bind(statement, start_index)
|
||||
} else {
|
||||
for i in 0..T::column_count() {
|
||||
dbg!(i);
|
||||
for _ in 0..T::column_count() {
|
||||
statement.bind_null(start_index)?;
|
||||
start_index += 1;
|
||||
}
|
||||
|
@ -272,17 +279,6 @@ impl<T: Bind, const COUNT: usize> Bind for [T; COUNT] {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Column + Default + Copy, const COUNT: usize> Column for [T; COUNT] {
|
||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||
let mut array = [Default::default(); COUNT];
|
||||
let mut current_index = start_index;
|
||||
for i in 0..COUNT {
|
||||
(array[i], current_index) = T::column(statement, current_index)?;
|
||||
}
|
||||
Ok((array, current_index))
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for &Path {}
|
||||
impl Bind for &Path {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
|
@ -315,6 +311,25 @@ impl Column for PathBuf {
|
|||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for uuid::Uuid {
|
||||
fn column_count() -> usize {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
impl Bind for uuid::Uuid {
|
||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||
self.as_bytes().bind(statement, start_index)
|
||||
}
|
||||
}
|
||||
|
||||
impl Column for uuid::Uuid {
|
||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||
let (bytes, next_index) = Column::column(statement, start_index)?;
|
||||
Ok((uuid::Uuid::from_bytes(bytes), next_index))
|
||||
}
|
||||
}
|
||||
|
||||
impl StaticColumnCount for () {
|
||||
fn column_count() -> usize {
|
||||
0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue