1 | | | import 'marshaling_context.dart'; |
2 | | |
|
3 | | | /// Base class to serialize/deserialize data of type [T] to a transferable type [S]. |
4 | | | abstract class SquadronMarshaler<T, S> { |
5 | | 44 | const SquadronMarshaler(); |
6 | | |
|
7 | | | /// Serialize [data] of type [T] to type [S], eg. a `String` or some binary representation. |
8 | | | /// `unmarshal(marshal(data))` must produce an instance of [T] that is equivalent to |
9 | | | /// original instance [data]. |
10 | | | S marshal(T data, [MarshalingContext? context]); |
11 | | |
|
12 | | | /// Deserialize a representation of type [S] back to the original data of type [T]. |
13 | | | /// `unmarshal(marshal(data))` must produce an instance of [T] that is equivalent to |
14 | | | /// original instance [data]. |
15 | | | T unmarshal(S data, [MarshalingContext? context]); |
16 | | | } |