mithril_persistence/sqlite/
cursor.rs1use sqlite::CursorWithOwnership;
2use std::marker::PhantomData;
3
4use super::SqLiteEntity;
5
6pub struct EntityCursor<'a, T> {
9 cursor: CursorWithOwnership<'a>,
10 phantom: PhantomData<T>,
11}
12
13impl<'a, T> EntityCursor<'a, T> {
14 pub fn new(cursor: CursorWithOwnership<'a>) -> Self {
16 Self {
17 cursor,
18 phantom: PhantomData,
19 }
20 }
21}
22
23impl<T> Iterator for EntityCursor<'_, T>
24where
25 T: SqLiteEntity,
26{
27 type Item = T;
28
29 fn next(&mut self) -> Option<T> {
33 self.cursor
34 .next()
35 .map(|res| T::hydrate(res.map_err(|e| panic!("{e}")).unwrap()).unwrap())
36 }
37}