This repository was archived by the owner on May 4, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +33
-15
lines changed
move-cli/src/sandbox/utils Expand file tree Collapse file tree 2 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,39 @@ impl<R: ModuleResolver> GetModule for ModuleCache<R> {
67
67
}
68
68
}
69
69
70
+ impl < R : ModuleResolver > GetModule for & R {
71
+ type Error = R :: Error ;
72
+ type Item = CompiledModule ;
73
+
74
+ fn get_module_by_id ( & self , id : & ModuleId ) -> Result < Option < CompiledModule > , Self :: Error > {
75
+ Ok ( self
76
+ . get_module ( id)
77
+ . unwrap ( )
78
+ . map ( |bytes| CompiledModule :: deserialize ( & bytes) . unwrap ( ) ) )
79
+ }
80
+ }
81
+
82
+ impl < R : ModuleResolver > GetModule for & mut R {
83
+ type Error = R :: Error ;
84
+ type Item = CompiledModule ;
85
+
86
+ fn get_module_by_id ( & self , id : & ModuleId ) -> Result < Option < CompiledModule > , Self :: Error > {
87
+ Ok ( self
88
+ . get_module ( id)
89
+ . unwrap ( )
90
+ . map ( |bytes| CompiledModule :: deserialize ( & bytes) . unwrap ( ) ) )
91
+ }
92
+ }
93
+
94
+ impl < T : GetModule > GetModule for Arc < T > {
95
+ type Error = T :: Error ;
96
+ type Item = T :: Item ;
97
+
98
+ fn get_module_by_id ( & self , id : & ModuleId ) -> Result < Option < T :: Item > , Self :: Error > {
99
+ self . as_ref ( ) . get_module_by_id ( id)
100
+ }
101
+ }
102
+
70
103
/// Simple in-memory module cache that implements Sync
71
104
pub struct SyncModuleCache < R : ModuleResolver > {
72
105
cache : RwLock < BTreeMap < ModuleId , Arc < CompiledModule > > > ,
Original file line number Diff line number Diff line change @@ -419,21 +419,6 @@ impl ResourceResolver for OnDiskStateView {
419
419
}
420
420
}
421
421
422
- impl GetModule for & OnDiskStateView {
423
- type Error = anyhow:: Error ;
424
- type Item = CompiledModule ;
425
-
426
- fn get_module_by_id ( & self , id : & ModuleId ) -> Result < Option < CompiledModule > , Self :: Error > {
427
- if let Some ( bytes) = self . get_module_bytes ( id) ? {
428
- let module = CompiledModule :: deserialize ( & bytes)
429
- . map_err ( |e| anyhow ! ( "Failure deserializing module {:?}: {:?}" , id, e) ) ?;
430
- Ok ( Some ( module) )
431
- } else {
432
- Ok ( None )
433
- }
434
- }
435
- }
436
-
437
422
impl Default for OnDiskStateView {
438
423
fn default ( ) -> Self {
439
424
OnDiskStateView :: create ( Path :: new ( DEFAULT_BUILD_DIR ) , Path :: new ( DEFAULT_STORAGE_DIR ) )
You can’t perform that action at this time.
0 commit comments