Skip to content

Commit

Permalink
Implement Send for ResultSet<'static, T> and Row
Browse files Browse the repository at this point in the history
  • Loading branch information
kubo committed Mar 25, 2024
1 parent 9da2db3 commit b31c836
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ New features:

* Add [`Row::column_info()`] to tell column names and types in [`RowValue::get()`]
* Change the lifetime parameter of [`ResultSet`] to `'static` when it is created by query methods of [`Connection`] or into_result_set methods of [`Statement`].
* `Send` is implemented for [`Statement`], [`SqlValue`], [`Object`] and [`Collection`].
* `Send` is implemented for the following types:
* [`Statement`]
* [`ResultSet<'static, T>`][`ResultSet`]
* [`Row`]
* [`SqlValue`]
* [`Object`]
* [`Collection`].

Changes:

Expand Down Expand Up @@ -459,6 +465,7 @@ Incompatible changes:
[`OracleType::Xml`]: https://www.jiubao.org/rust-oracle/oracle/sql_type/enum.OracleType.html#variant.Xml
[`ResultSet`]: https://www.jiubao.org/rust-oracle/oracle/struct.ResultSet.html
[`ResultSet::column_info()`]: https://www.jiubao.org/rust-oracle/oracle/struct.ResultSet.html#method.column_info
[`Row`]: https://www.jiubao.org/rust-oracle/oracle/struct.Row.html
[`Row::column_info()`]: https://www.jiubao.org/rust-oracle/oracle/struct.Row.html#method.column_info
[`Row::sql_values()`]: https://www.jiubao.org/rust-oracle/oracle/struct.Row.html#method.sql_values
[`Row::get_as()`]: https://www.jiubao.org/rust-oracle/oracle/struct.Row.html#method.get_as
Expand Down
5 changes: 5 additions & 0 deletions src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::sync::Arc;

use crate::sql_type::FromSql;
use crate::statement::Stmt;
use crate::AssertSend;
use crate::ColumnIndex;
use crate::ColumnInfo;
#[cfg(doc)]
Expand Down Expand Up @@ -92,6 +93,8 @@ impl Row {
}
}

impl AssertSend for Row {}

impl fmt::Debug for Row {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Row {{ ")?;
Expand Down Expand Up @@ -167,6 +170,8 @@ where
}
}

unsafe impl<T> Send for ResultSet<'static, T> where T: RowValue {}

impl<'stmt, T> Iterator for ResultSet<'stmt, T>
where
T: RowValue,
Expand Down
2 changes: 2 additions & 0 deletions src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ impl Stmt {
}
}

impl AssertSend for Stmt {}

impl Drop for Stmt {
fn drop(&mut self) {
let _ = self.close();
Expand Down

0 comments on commit b31c836

Please sign in to comment.