@@ -451,7 +451,12 @@ where
451451 self . mutate_with ( id, |current| async move { Ok ( f ( current. as_ref ( ) ) ) } ) . await
452452 }
453453
454- async fn mutate_with < F , Fut > ( & self , id : & SO :: Id , f : F ) -> Result < Option < SO > , Error >
454+ /// Like [`Self::mutate`], but allows the transformation to await fallible reads.
455+ ///
456+ /// The mutation lock remains held while `f` runs. This is useful when the new state must be
457+ /// decided from an async read of another store without letting a concurrent writer invalidate
458+ /// that decision. Callers must keep cross-store lock ordering consistent to avoid deadlocks.
459+ pub ( crate ) async fn mutate_with < F , Fut > ( & self , id : & SO :: Id , f : F ) -> Result < Option < SO > , Error >
455460 where
456461 F : FnOnce ( Option < SO > ) -> Fut ,
457462 Fut : Future < Output = Result < Option < SO > , Error > > ,
@@ -470,19 +475,6 @@ where
470475 Ok ( Some ( new_object) )
471476 }
472477
473- /// Like [`Self::mutate`], but allows the transformation to await fallible reads.
474- ///
475- /// The mutation lock remains held while `f` runs. This is useful when the new state must be
476- /// decided from an async read of another store without letting a concurrent writer invalidate
477- /// that decision. Callers must keep cross-store lock ordering consistent to avoid deadlocks.
478- pub ( crate ) async fn mutate_async < F , Fut > ( & self , id : & SO :: Id , f : F ) -> Result < Option < SO > , Error >
479- where
480- F : FnOnce ( Option < SO > ) -> Fut ,
481- Fut : Future < Output = Result < Option < SO > , Error > > ,
482- {
483- self . mutate_with ( id, f) . await
484- }
485-
486478 /// Returns whether an object is stored under `id`.
487479 pub ( crate ) async fn contains_key ( & self , id : & SO :: Id ) -> Result < bool , Error > {
488480 let _guard = self . mutation_lock . read ( ) . await ;
@@ -1260,7 +1252,7 @@ mod tests {
12601252 }
12611253
12621254 #[ tokio:: test]
1263- async fn mutate_async_awaits_fallible_reads ( ) {
1255+ async fn mutate_with_awaits_fallible_reads ( ) {
12641256 let store: Arc < DynStore > = Arc :: new ( DynStoreWrapper ( InMemoryStore :: new ( ) ) ) ;
12651257 let logger = Arc :: new ( TestLogger :: new ( ) ) ;
12661258 let id = TestObjectId { id : [ 42u8 ; 4 ] } ;
@@ -1285,7 +1277,7 @@ mod tests {
12851277 ) ;
12861278
12871279 let result = data_store
1288- . mutate_async ( & id, |existing| async move {
1280+ . mutate_with ( & id, |existing| async move {
12891281 let mut updated = existing. unwrap ( ) ;
12901282 updated. data = other_store. get ( & other_id) . await ?. unwrap ( ) . data ;
12911283 Ok ( Some ( updated) )
0 commit comments