@@ -170,28 +170,21 @@ pub(crate) struct Transaction<'h> {
170
170
altered_files : HashSet < FileId > ,
171
171
}
172
172
173
- // TODO: Implement this, so the .read method doesn't need to exist: writable transactions should
174
- // passthrough to read methods automatically.
173
+ // TODO: Try doing this with a read trait that just requires a rusqlite::Transaction be available.
175
174
176
- // impl<'h> Deref for Transaction<'h> {
177
- // type Target = ReadTransaction<&'h rusqlite::Transaction<'h>>;
178
- //
179
- // fn deref(&self) -> &Self::Target {
180
- // unsafe {
181
- // &ReadTransaction {
182
- // tx: ReadOnlyRusqliteTransaction { conn: &self.tx },
183
- // }
184
- // }
185
- // }
186
- // }
175
+ impl < ' h > Deref for Transaction < ' h > {
176
+ type Target = ReadTransaction < rusqlite:: Transaction < ' h > > ;
187
177
188
- impl < ' h > Transaction < ' h > {
189
- pub fn read ( & self ) -> ReadTransaction < & rusqlite:: Transaction > {
190
- ReadTransaction {
191
- tx : ReadOnlyRusqliteTransaction { conn : & self . tx } ,
178
+ fn deref ( & self ) -> & Self :: Target {
179
+ unsafe {
180
+ std:: mem:: transmute :: < & rusqlite:: Transaction , & ReadTransaction < rusqlite:: Transaction > > (
181
+ & self . tx ,
182
+ )
192
183
}
193
184
}
185
+ }
194
186
187
+ impl < ' h > Transaction < ' h > {
195
188
pub fn new ( tx : rusqlite:: Transaction < ' h > , handle : & ' h Handle ) -> Self {
196
189
Self {
197
190
tx,
@@ -353,7 +346,6 @@ impl<'h> Transaction<'h> {
353
346
if let Some ( max) = self . handle . instance_limits . max_value_length_sum {
354
347
loop {
355
348
let actual = self
356
- . read ( )
357
349
. sum_value_length ( )
358
350
. context ( "reading value_length sum" ) ?;
359
351
if actual <= max {
0 commit comments