@@ -2,6 +2,7 @@ mod coefficient;
2
2
mod core;
3
3
pub mod representation;
4
4
5
+ use bincode:: { de:: read:: Reader , enc:: write:: Writer , Decode , Encode } ;
5
6
use representation:: InlineVar ;
6
7
7
8
use crate :: {
@@ -20,6 +21,7 @@ pub use self::representation::{
20
21
} ;
21
22
use self :: representation:: { FunView , RawAtom } ;
22
23
24
+ use std:: result;
23
25
/// A symbol, for example the name of a variable or the name of a function,
24
26
/// together with its properties.
25
27
/// Should be created using [State::get_symbol].
@@ -33,6 +35,49 @@ pub struct Symbol {
33
35
is_linear : bool ,
34
36
}
35
37
38
+ impl < __Context > :: bincode:: Decode < __Context > for Symbol {
39
+ fn decode < __D : :: bincode:: de:: Decoder < Context = __Context > > (
40
+ decoder : & mut __D ,
41
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
42
+ Ok ( Self {
43
+ id : :: bincode:: Decode :: decode ( decoder) ?,
44
+ wildcard_level : :: bincode:: Decode :: decode ( decoder) ?,
45
+ is_symmetric : :: bincode:: Decode :: decode ( decoder) ?,
46
+ is_antisymmetric : :: bincode:: Decode :: decode ( decoder) ?,
47
+ is_cyclesymmetric : :: bincode:: Decode :: decode ( decoder) ?,
48
+ is_linear : :: bincode:: Decode :: decode ( decoder) ?,
49
+ } )
50
+ }
51
+ }
52
+ impl < ' __de , __Context > :: bincode:: BorrowDecode < ' __de , __Context > for Symbol {
53
+ fn borrow_decode < __D : :: bincode:: de:: BorrowDecoder < ' __de , Context = __Context > > (
54
+ decoder : & mut __D ,
55
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
56
+ Ok ( Self {
57
+ id : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
58
+ wildcard_level : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
59
+ is_symmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
60
+ is_antisymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
61
+ is_cyclesymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
62
+ is_linear : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
63
+ } )
64
+ }
65
+ }
66
+
67
+ impl :: bincode:: Encode for Symbol {
68
+ fn encode < __E : :: bincode:: enc:: Encoder > (
69
+ & self ,
70
+ encoder : & mut __E ,
71
+ ) -> Result < ( ) , :: bincode:: error:: EncodeError > {
72
+ :: bincode:: Encode :: encode ( & self . id , encoder) ?;
73
+ :: bincode:: Encode :: encode ( & self . wildcard_level , encoder) ?;
74
+ :: bincode:: Encode :: encode ( & self . is_symmetric , encoder) ?;
75
+ :: bincode:: Encode :: encode ( & self . is_antisymmetric , encoder) ?;
76
+ :: bincode:: Encode :: encode ( & self . is_cyclesymmetric , encoder) ?;
77
+ :: bincode:: Encode :: encode ( & self . is_linear , encoder) ?;
78
+ Ok ( ( ) )
79
+ }
80
+ }
36
81
impl std:: fmt:: Debug for Symbol {
37
82
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
38
83
f. write_fmt ( format_args ! ( "{}" , self . id) ) ?;
0 commit comments