forked from transact-rs/sqlx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdone.rs
More file actions
42 lines (36 loc) · 958 Bytes
/
Copy pathdone.rs
File metadata and controls
42 lines (36 loc) · 958 Bytes
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
use crate::done::Done;
use crate::sqlite::Sqlite;
use std::iter::{Extend, IntoIterator};
#[derive(Debug, Default)]
pub struct SqliteDone {
pub(super) changes: u64,
pub(super) last_insert_rowid: i64,
}
impl SqliteDone {
pub fn last_insert_rowid(&self) -> i64 {
self.last_insert_rowid
}
}
impl Done for SqliteDone {
type Database = Sqlite;
fn rows_affected(&self) -> u64 {
self.changes
}
}
impl Extend<SqliteDone> for SqliteDone {
fn extend<T: IntoIterator<Item = SqliteDone>>(&mut self, iter: T) {
for elem in iter {
self.changes += elem.changes;
self.last_insert_rowid = elem.last_insert_rowid;
}
}
}
#[cfg(feature = "any")]
impl From<SqliteDone> for crate::any::AnyDone {
fn from(done: SqliteDone) -> Self {
crate::any::AnyDone {
rows_affected: done.changes,
last_insert_id: Some(done.last_insert_rowid),
}
}
}