openShardsEncodedWire method
Uint8List
openShardsEncodedWire({
- required Uint8List skeletonBytes,
- Uint8List? skeletonKey,
- required Uint8List requestBytes,
- required RitoPinnedFontPolicy pinnedFontPolicy,
Opens a reader from a publication's skeleton shard and requests its
initial artifact, returning the encoded RITOART1.
When the initial request waits on content shards this throws a RitoNativeException with ritoNativeStatusResourcePending and the shards to supply, and the native session stays open: supply them with supplyShard and request the artifact again under a newer request ID.
Implementation
Uint8List openShardsEncodedWire({
required Uint8List skeletonBytes,
Uint8List? skeletonKey,
required Uint8List requestBytes,
required RitoPinnedFontPolicy pinnedFontPolicy,
}) {
_validateInput(skeletonBytes, 512 * 1024 * 1024, 'skeleton');
_validateInput(requestBytes, 16 * 1024 * 1024, 'request');
_validateShardKey(skeletonKey);
final skeleton = _copyInput(skeletonBytes);
final key = _copyInput(skeletonKey ?? Uint8List(0));
final request = _copyInput(requestBytes);
final artifactOut = calloc<_RitoOwnedBuffer>();
final errorOut = calloc<_RitoOwnedBuffer>();
final faceAllocations = <Pointer<NativeType>>[];
try {
final faces = _marshalPinnedFontFaces(pinnedFontPolicy, faceAllocations);
final status = _openShards(
skeleton,
skeletonBytes.length,
key,
skeletonKey?.length ?? 0,
request,
requestBytes.length,
faces,
pinnedFontPolicy.faces.length,
artifactOut,
errorOut,
);
if (status != 0) {
throw _nativeError(status, errorOut);
}
try {
return _copyOutput(artifactOut, 'artifact');
} on Object catch (error, stackTrace) {
_disposeAfterFailedSessionOutput(
_acceptedRequestSessionId(requestBytes),
);
Error.throwWithStackTrace(
_terminatedSessionResultError('initial artifact', error),
stackTrace,
);
}
} finally {
_bufferFree(artifactOut);
_bufferFree(errorOut);
calloc
..free(artifactOut)
..free(errorOut)
..free(skeleton)
..free(key)
..free(request);
for (final allocation in faceAllocations) {
calloc.free(allocation);
}
}
}