File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ pub trait ChipUsageGetter {
37
37
}
38
38
}
39
39
40
+ /// A chip whose state could be persisted.
41
+ pub trait Stateful < S > {
42
+ fn load_state ( & mut self , state : S ) ;
43
+ fn store_state ( & self ) -> S ;
44
+ }
45
+
40
46
impl < SC : StarkGenericConfig , C : Chip < SC > > Chip < SC > for RefCell < C > {
41
47
fn air ( & self ) -> Arc < dyn AnyRap < SC > > {
42
48
self . borrow ( ) . air ( )
@@ -140,3 +146,12 @@ impl<C: ChipUsageGetter> ChipUsageGetter for Mutex<C> {
140
146
self . lock ( ) . unwrap ( ) . trace_width ( )
141
147
}
142
148
}
149
+
150
+ impl < S , C : Stateful < S > > Stateful < S > for RefCell < C > {
151
+ fn load_state ( & mut self , state : S ) {
152
+ self . borrow_mut ( ) . load_state ( state)
153
+ }
154
+ fn store_state ( & self ) -> S {
155
+ self . borrow_mut ( ) . store_state ( )
156
+ }
157
+ }
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ pub mod utils;
41
41
/// Verifier implementation
42
42
pub mod verifier;
43
43
44
- pub use chip:: { Chip , ChipUsageGetter } ;
44
+ pub use chip:: { Chip , ChipUsageGetter , Stateful } ;
45
45
46
46
// Use jemalloc as global allocator for performance
47
47
#[ cfg( all( feature = "jemalloc" , unix, not( test) ) ) ]
You can’t perform that action at this time.
0 commit comments