@@ -43,6 +43,7 @@ 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 representation:: InlineVar ;
47
48
use smartstring:: { LazyCompact , SmartString } ;
48
49
@@ -63,6 +64,7 @@ pub use self::representation::{
63
64
} ;
64
65
use self :: representation:: { FunView , RawAtom } ;
65
66
67
+
66
68
/// A function that is called after normalization of the arguments.
67
69
/// If the input, the first argument, is normalized, the function should return `false`.
68
70
/// Otherwise, the function must return `true` and set the second argument to the normalized value.
@@ -97,6 +99,7 @@ pub enum FunctionAttribute {
97
99
Linear ,
98
100
}
99
101
102
+ use std:: result;
100
103
/// A symbol, for example the name of a variable or the name of a function,
101
104
/// together with its properties.
102
105
///
@@ -124,6 +127,49 @@ pub struct Symbol {
124
127
is_linear : bool ,
125
128
}
126
129
130
+ impl < __Context > :: bincode:: Decode < __Context > for Symbol {
131
+ fn decode < __D : :: bincode:: de:: Decoder < Context = __Context > > (
132
+ decoder : & mut __D ,
133
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
134
+ Ok ( Self {
135
+ id : :: bincode:: Decode :: decode ( decoder) ?,
136
+ wildcard_level : :: bincode:: Decode :: decode ( decoder) ?,
137
+ is_symmetric : :: bincode:: Decode :: decode ( decoder) ?,
138
+ is_antisymmetric : :: bincode:: Decode :: decode ( decoder) ?,
139
+ is_cyclesymmetric : :: bincode:: Decode :: decode ( decoder) ?,
140
+ is_linear : :: bincode:: Decode :: decode ( decoder) ?,
141
+ } )
142
+ }
143
+ }
144
+ impl < ' __de , __Context > :: bincode:: BorrowDecode < ' __de , __Context > for Symbol {
145
+ fn borrow_decode < __D : :: bincode:: de:: BorrowDecoder < ' __de , Context = __Context > > (
146
+ decoder : & mut __D ,
147
+ ) -> Result < Self , :: bincode:: error:: DecodeError > {
148
+ Ok ( Self {
149
+ id : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
150
+ wildcard_level : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
151
+ is_symmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
152
+ is_antisymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
153
+ is_cyclesymmetric : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
154
+ is_linear : :: bincode:: BorrowDecode :: < ' _ , __Context > :: borrow_decode ( decoder) ?,
155
+ } )
156
+ }
157
+ }
158
+
159
+ impl :: bincode:: Encode for Symbol {
160
+ fn encode < __E : :: bincode:: enc:: Encoder > (
161
+ & self ,
162
+ encoder : & mut __E ,
163
+ ) -> Result < ( ) , :: bincode:: error:: EncodeError > {
164
+ :: bincode:: Encode :: encode ( & self . id , encoder) ?;
165
+ :: bincode:: Encode :: encode ( & self . wildcard_level , encoder) ?;
166
+ :: bincode:: Encode :: encode ( & self . is_symmetric , encoder) ?;
167
+ :: bincode:: Encode :: encode ( & self . is_antisymmetric , encoder) ?;
168
+ :: bincode:: Encode :: encode ( & self . is_cyclesymmetric , encoder) ?;
169
+ :: bincode:: Encode :: encode ( & self . is_linear , encoder) ?;
170
+ Ok ( ( ) )
171
+ }
172
+ }
127
173
impl std:: fmt:: Debug for Symbol {
128
174
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
129
175
f. write_fmt ( format_args ! ( "{}" , self . id) ) ?;
0 commit comments