Skip to content

Commit b0fbe29

Browse files
committed
Make IntoOwnedRow cache generic
1 parent 32278e9 commit b0fbe29

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

diesel/src/row.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use crate::backend::Backend;
44
use crate::deserialize;
55
use deserialize::FromSql;
6+
use std::default::Default;
67
use std::ops::Range;
7-
use std::sync::Arc;
88

99
#[cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes")]
1010
#[doc(inline)]
@@ -157,8 +157,11 @@ pub trait IntoOwnedRow<'a, DB: Backend>: Row<'a, DB> {
157157
/// The owned version of the row
158158
type OwnedRow: Row<'a, DB> + Send + 'static;
159159

160+
/// A store for cached information between rows for faster access
161+
type Cache: Default + 'static;
162+
160163
/// Turn the row into its owned version
161-
fn into_owned(self, column_name_cache: &mut Option<Arc<[Option<String>]>>) -> Self::OwnedRow;
164+
fn into_owned(self, cache: &mut Self::Cache) -> Self::OwnedRow;
162165
}
163166

164167
// These traits are not part of the public API

diesel/src/sqlite/connection/row.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ pub(super) enum PrivateSqliteRow<'stmt, 'query> {
2626
impl<'stmt> IntoOwnedRow<'stmt, Sqlite> for SqliteRow<'stmt, '_> {
2727
type OwnedRow = OwnedSqliteRow;
2828

29-
fn into_owned(self, column_name_cache: &mut Option<Arc<[Option<String>]>>) -> Self::OwnedRow {
29+
type Cache = Option<Arc<[Option<String>]>>;
30+
31+
fn into_owned(self, column_name_cache: &mut Self::Cache) -> Self::OwnedRow {
3032
self.inner.borrow().moveable(column_name_cache)
3133
}
3234
}

0 commit comments

Comments
 (0)