mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-27 00:15:26 -04:00
checkpoint
This commit is contained in:
parent
bf813d7d0f
commit
20bdf07f24
10 changed files with 329 additions and 218 deletions
19
lib/tools/protobuf_tools.dart
Normal file
19
lib/tools/protobuf_tools.dart
Normal 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);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue