checkpoint

This commit is contained in:
Christien Rioux 2023-07-19 00:09:57 -04:00
parent bf813d7d0f
commit 20bdf07f24
10 changed files with 329 additions and 218 deletions

View file

@ -0,0 +1,19 @@
import 'package:protobuf/protobuf.dart';
import 'dart:typed_data';
Future<Uint8List> protobufUpdateBytes<T extends GeneratedMessage>(
T Function(List<int>) fromBuffer,
Uint8List oldBytes,
Future<T> Function(T) update) async {
T oldObj = fromBuffer(oldBytes);
T newObj = await update(oldObj);
return Uint8List.fromList(newObj.writeToBuffer());
}
Future<Uint8List> Function(Uint8List)
protobufUpdate<T extends GeneratedMessage>(
T Function(List<int>) fromBuffer, Future<T> Function(T) update) {
return (Uint8List oldBytes) {
return protobufUpdateBytes(fromBuffer, oldBytes, update);
};
}