@@ -43,7 +43,9 @@ mod coefficient;
43
43
mod core;
44
44
pub mod representation;
45
45
46
+ use bincode:: { de:: read:: Reader , enc:: write:: Writer , Decode , Encode } ;
46
47
use colored:: Colorize ;
48
+
47
49
use representation:: InlineVar ;
48
50
use smartstring:: { LazyCompact , SmartString } ;
49
51
@@ -287,6 +289,7 @@ pub enum FunctionAttribute {
287
289
Linear ,
288
290
}
289
291
292
+ use std:: result;
290
293
/// A symbol, for example the name of a variable or the name of a function,
291
294
/// together with its properties.
292
295
///
@@ -313,6 +316,49 @@ pub struct Symbol {
313
316
is_linear : bool ,
314
317
}
315
318
319
+ impl < __Context > :: bincode:: Decode < __Context > for Symbol {
320
+ fn decode < __D : :: bincode:: de:: Decoder < Context = __Context > > (
321
+ decoder : & mut __D ,
322
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
323
+ Ok ( Self {
324
+ id : :: bincode:: Decode :: decode ( decoder) ?,
325
+ wildcard_level : :: bincode:: Decode :: decode ( decoder) ?,
326
+ is_symmetric : :: bincode:: Decode :: decode ( decoder) ?,
327
+ is_antisymmetric : :: bincode:: Decode :: decode ( decoder) ?,
328
+ is_cyclesymmetric : :: bincode:: Decode :: decode ( decoder) ?,
329
+ is_linear : :: bincode:: Decode :: decode ( decoder) ?,
330
+ } )
331
+ }
332
+ }
333
+ impl < ' __de , __Context > :: bincode:: BorrowDecode < ' __de , __Context > for Symbol {
334
+ fn borrow_decode < __D : :: bincode:: de:: BorrowDecoder < ' __de , Context = __Context > > (
335
+ decoder : & mut __D ,
336
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
337
+ Ok ( Self {
338
+ id : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
339
+ wildcard_level : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
340
+ is_symmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
341
+ is_antisymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
342
+ is_cyclesymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
343
+ is_linear : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
344
+ } )
345
+ }
346
+ }
347
+
348
+ impl :: bincode:: Encode for Symbol {
349
+ fn encode < __E : :: bincode:: enc:: Encoder > (
350
+ & self ,
351
+ encoder : & mut __E ,
352
+ ) -> Result < ( ) , :: bincode:: error:: EncodeError > {
353
+ :: bincode:: Encode :: encode ( & self . id , encoder) ?;
354
+ :: bincode:: Encode :: encode ( & self . wildcard_level , encoder) ?;
355
+ :: bincode:: Encode :: encode ( & self . is_symmetric , encoder) ?;
356
+ :: bincode:: Encode :: encode ( & self . is_antisymmetric , encoder) ?;
357
+ :: bincode:: Encode :: encode ( & self . is_cyclesymmetric , encoder) ?;
358
+ :: bincode:: Encode :: encode ( & self . is_linear , encoder) ?;
359
+ Ok ( ( ) )
360
+ }
361
+ }
316
362
impl std:: fmt:: Debug for Symbol {
317
363
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
318
364
f. write_fmt ( format_args ! ( "{}" , self . id) ) ?;
0 commit comments