Skip to main content

sqlx_odbc/
query_result.rs

1/// Result summary for an ODBC query.
2#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
3pub struct OdbcQueryResult {
4    rows_affected: u64,
5}
6
7impl OdbcQueryResult {
8    /// Creates a query result with the given affected-row count.
9    pub const fn new(rows_affected: u64) -> Self {
10        Self { rows_affected }
11    }
12
13    /// Returns the number of rows affected by the query.
14    pub const fn rows_affected(&self) -> u64 {
15        self.rows_affected
16    }
17}
18
19impl Extend<Self> for OdbcQueryResult {
20    fn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T) {
21        self.rows_affected += iter
22            .into_iter()
23            .map(|result| result.rows_affected)
24            .sum::<u64>();
25    }
26}