|
@@ -1,4 +1,6 @@
|
|
|
-use super::{EntityDatum, EntityDatumList};
|
|
|
+use crate::{db::DBConnection, DBResult};
|
|
|
+
|
|
|
+use super::EntityDatum;
|
|
|
|
|
|
impl EntityDatum for String {
|
|
|
fn sql_type() -> &'static str {
|
|
@@ -9,6 +11,17 @@ impl EntityDatum for String {
|
|
|
stmt.bind((index, self.as_str()))
|
|
|
.expect("couldn't bind string");
|
|
|
}
|
|
|
+
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ stmt: &mut sqlite::Statement<'a>,
|
|
|
+ index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ Ok((stmt.read(index)?, index + 1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl EntityDatum for usize {
|
|
@@ -20,6 +33,17 @@ impl EntityDatum for usize {
|
|
|
stmt.bind((index, *self as i64))
|
|
|
.expect("couldn't bind usize as i64");
|
|
|
}
|
|
|
+
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ stmt: &mut sqlite::Statement<'a>,
|
|
|
+ index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ Ok((stmt.read::<i64, _>(index)? as usize, index + 1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl EntityDatum for isize {
|
|
@@ -27,9 +51,20 @@ impl EntityDatum for isize {
|
|
|
"int"
|
|
|
}
|
|
|
|
|
|
- fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, index: usize) {
|
|
|
+ fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, _index: usize) {
|
|
|
todo!()
|
|
|
}
|
|
|
+
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ stmt: &mut sqlite::Statement<'a>,
|
|
|
+ index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ Ok((stmt.read::<i64, _>(index)? as isize, index + 1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl EntityDatum for u64 {
|
|
@@ -37,9 +72,20 @@ impl EntityDatum for u64 {
|
|
|
"int"
|
|
|
}
|
|
|
|
|
|
- fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, index: usize) {
|
|
|
+ fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, _index: usize) {
|
|
|
todo!()
|
|
|
}
|
|
|
+
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ stmt: &mut sqlite::Statement<'a>,
|
|
|
+ index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ Ok((stmt.read::<i64, _>(index)? as u64, index + 1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl EntityDatum for i64 {
|
|
@@ -47,9 +93,20 @@ impl EntityDatum for i64 {
|
|
|
"int"
|
|
|
}
|
|
|
|
|
|
- fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, index: usize) {
|
|
|
+ fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, _index: usize) {
|
|
|
todo!()
|
|
|
}
|
|
|
+
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ stmt: &mut sqlite::Statement<'a>,
|
|
|
+ index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ Ok((stmt.read(index)?, index + 1))
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl<T: EntityDatum> EntityDatum for Option<T> {
|
|
@@ -57,49 +114,19 @@ impl<T: EntityDatum> EntityDatum for Option<T> {
|
|
|
T::sql_type()
|
|
|
}
|
|
|
|
|
|
- fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, index: usize) {
|
|
|
+ fn bind_to<'a>(&self, _stmt: &mut sqlite::Statement<'a>, _index: usize) {
|
|
|
todo!()
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
-impl EntityDatumList for () {
|
|
|
- fn accept(&self, _: &mut impl super::EntityDatumListVisitor) {}
|
|
|
-}
|
|
|
|
|
|
-impl<T: EntityDatum> EntityDatumList for T {
|
|
|
- fn accept(&self, visitor: &mut impl super::EntityDatumListVisitor) {
|
|
|
- visitor.visit(self);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T0: EntityDatum> EntityDatumList for (T0,) {
|
|
|
- fn accept(&self, visitor: &mut impl super::EntityDatumListVisitor) {
|
|
|
- visitor.visit(&self.0);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T0: EntityDatum, T1: EntityDatum> EntityDatumList for (T0, T1) {
|
|
|
- fn accept(&self, visitor: &mut impl super::EntityDatumListVisitor) {
|
|
|
- visitor.visit(&self.0);
|
|
|
- visitor.visit(&self.1);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T0: EntityDatum, T1: EntityDatum, T2: EntityDatum> EntityDatumList for (T0, T1, T2) {
|
|
|
- fn accept(&self, visitor: &mut impl super::EntityDatumListVisitor) {
|
|
|
- visitor.visit(&self.0);
|
|
|
- visitor.visit(&self.1);
|
|
|
- visitor.visit(&self.2);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-impl<T0: EntityDatum, T1: EntityDatum, T2: EntityDatum, T3: EntityDatum> EntityDatumList
|
|
|
- for (T0, T1, T2, T3)
|
|
|
-{
|
|
|
- fn accept(&self, visitor: &mut impl super::EntityDatumListVisitor) {
|
|
|
- visitor.visit(&self.0);
|
|
|
- visitor.visit(&self.1);
|
|
|
- visitor.visit(&self.2);
|
|
|
- visitor.visit(&self.3);
|
|
|
+ fn build_from<'a>(
|
|
|
+ _: &DBConnection,
|
|
|
+ _stmt: &mut sqlite::Statement<'a>,
|
|
|
+ _index: usize,
|
|
|
+ ) -> DBResult<(Self, usize)>
|
|
|
+ where
|
|
|
+ Self: Sized,
|
|
|
+ {
|
|
|
+ // Ok((stmt.read::<i64, _>(index)? as u64, index+1))
|
|
|
+ todo!()
|
|
|
}
|
|
|
}
|