BcsType<T, Input> constructor
BcsType<T, Input> ({
- required String name,
- required T read(),
- required void write(
- Input,
- BcsWriter
- Uint8List serialize(
- Input, {
- BcsWriterOptions? options,
- int? serializedSize(
- Input, {
- BcsWriterOptions? options,
- void validate(
- Input
Implementation
BcsType({
required this.name,
required this.read,
required void Function(Input, BcsWriter) write,
Uint8List Function(Input, {BcsWriterOptions? options})? serialize,
int? Function(Input, {BcsWriterOptions? options})? serializedSize,
void Function(Input)? validate,
}) :
this.serializedSize = serializedSize ?? ((_, {BcsWriterOptions? options}) => null),
this._write = write,
this._serialize = serialize ?? ((value, {options}) {
final writer = BcsWriter(
size: options?.size ?? serializedSize?.call(value) ?? 1024,
maxSize: options?.maxSize,
allocateSize: options?.allocateSize ?? 1024
);
write(value, writer);
return writer.toBytes();
}),
this.validate = validate ?? ((_) {});