encodeAdjacent method

Uint8List encodeAdjacent(
  1. RitoAdjacentRequest request
)

Implementation

Uint8List encodeAdjacent(RitoAdjacentRequest request) {
  final writer = _Writer.message(ascii.encode('RITONAV1'), 1);
  writer.externalId(request.sessionId, 'session id');
  writer.externalId(request.requestId, 'request id');
  writer.externalId(request.fromArtifactId, 'from artifact id');
  writer.uint32(
    request.direction == RitoAdjacentDirection.previous ? 0 : 1,
    'adjacent direction',
  );
  writer.uint32(
    request.work.maxTopLevelNodesPerQuantum,
    'max top-level nodes per quantum',
  );
  writer.uint32(request.work.maxForegroundQuanta, 'max foreground quanta');
  writer.uint32(request.work.localPageCap, 'local page cap');
  final bytes = writer.finish();
  if (bytes.length != 60) {
    throw StateError('RITONAV1 must be exactly 60 bytes.');
  }
  return bytes;
}