encodeStateFromSnapshotV1 method

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

Implementation

Result<Uint8List, Error> encodeStateFromSnapshotV1({
  required YDoc doc,
  required YSnapshot snapshot,
}) {
  final results =
      _encodeStateFromSnapshotV1([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);
}