@@ -48,7 +48,13 @@ pub struct State {
4848impl Storable for State {
4949 const BOUND : Bound = Bound :: Unbounded ;
5050
51- fn to_bytes ( & self ) -> Cow < [ u8 ] > {
51+ fn into_bytes ( self ) -> Vec < u8 > {
52+ let mut buf = vec ! [ ] ;
53+ into_writer ( & self , & mut buf) . expect ( "failed to encode State data" ) ;
54+ buf
55+ }
56+
57+ fn to_bytes ( & self ) -> Cow < ' _ , [ u8 ] > {
5258 let mut buf = vec ! [ ] ;
5359 into_writer ( self , & mut buf) . expect ( "failed to encode State data" ) ;
5460 Cow :: Owned ( buf)
@@ -219,7 +225,13 @@ impl ChannelSetting {
219225impl Storable for Channel {
220226 const BOUND : Bound = Bound :: Unbounded ;
221227
222- fn to_bytes ( & self ) -> Cow < [ u8 ] > {
228+ fn into_bytes ( self ) -> Vec < u8 > {
229+ let mut buf = vec ! [ ] ;
230+ into_writer ( & self , & mut buf) . expect ( "failed to encode Channel data" ) ;
231+ buf
232+ }
233+
234+ fn to_bytes ( & self ) -> Cow < ' _ , [ u8 ] > {
223235 let mut buf = vec ! [ ] ;
224236 into_writer ( self , & mut buf) . expect ( "failed to encode Channel data" ) ;
225237 Cow :: Owned ( buf)
@@ -260,7 +272,13 @@ impl Message {
260272impl Storable for Message {
261273 const BOUND : Bound = Bound :: Unbounded ;
262274
263- fn to_bytes ( & self ) -> Cow < [ u8 ] > {
275+ fn into_bytes ( self ) -> Vec < u8 > {
276+ let mut buf = vec ! [ ] ;
277+ into_writer ( & self , & mut buf) . expect ( "failed to encode Message data" ) ;
278+ buf
279+ }
280+
281+ fn to_bytes ( & self ) -> Cow < ' _ , [ u8 ] > {
264282 let mut buf = vec ! [ ] ;
265283 into_writer ( self , & mut buf) . expect ( "failed to encode Message data" ) ;
266284 Cow :: Owned ( buf)
@@ -280,7 +298,13 @@ impl Storable for MessageId {
280298 is_fixed_size : false ,
281299 } ;
282300
283- fn to_bytes ( & self ) -> Cow < [ u8 ] > {
301+ fn into_bytes ( self ) -> Vec < u8 > {
302+ let mut buf = vec ! [ ] ;
303+ into_writer ( & self , & mut buf) . expect ( "failed to encode MessageId data" ) ;
304+ buf
305+ }
306+
307+ fn to_bytes ( & self ) -> Cow < ' _ , [ u8 ] > {
284308 let mut buf = vec ! [ ] ;
285309 into_writer ( self , & mut buf) . expect ( "failed to encode MessageId data" ) ;
286310 Cow :: Owned ( buf)
@@ -305,7 +329,7 @@ thread_local! {
305329 StableCell :: init(
306330 MEMORY_MANAGER . with_borrow( |m| m. get( STATE_MEMORY_ID ) ) ,
307331 Vec :: new( )
308- ) . expect ( "failed to init STATE store" )
332+ )
309333 ) ;
310334
311335 static CHANNEL_STORE : RefCell <StableBTreeMap <u32 , Channel , Memory >> = RefCell :: new(
@@ -377,9 +401,7 @@ pub mod state {
377401 STATE_STORE . with ( |r| {
378402 let mut buf = vec ! [ ] ;
379403 into_writer ( & ( * h. borrow ( ) ) , & mut buf) . expect ( "failed to encode STATE_STORE data" ) ;
380- r. borrow_mut ( )
381- . set ( buf)
382- . expect ( "failed to set STATE_STORE data" ) ;
404+ r. borrow_mut ( ) . set ( buf) ;
383405 } ) ;
384406 } ) ;
385407 }
0 commit comments