encodeStateFromSnapshotV2 method

Result<Uint8List, Error> encodeStateFromSnapshotV2({
  1. required YDoc doc,
  2. required YSnapshot snapshot,
})

Implementation

Result<Uint8List, Error> encodeStateFromSnapshotV2({
  required YDoc doc,
  required YSnapshot snapshot,
}) {
  final results = _encodeStateFromSnapshotV2([
    doc.toWasm(),
    snapshot.toWasm(),
  ]);
  final result = results[0];
  return Result.fromJson(
    result,
    (ok) => (ok is Uint8List ? ok : Uint8List.fromList((ok! as List).cast())),
    (error) => error is String ? error : (error! as ParsedString).value,
  );
}