streamCallWithBuffer function
StreamBufferFetchResult?
streamCallWithBuffer(
- StreamBufferCallback fn, {
- int? maxSize,
- int? initialSize,
- bool? allowZeroCopy,
Like callWithBuffer for stream fetch callbacks that also return hasMore.
Prefer passing initialSize equal to the stream chunkSize so the first
allocation matches the native copy budget and avoids a -2 resize round-trip.
Streaming payloads are typically large; this path uses a transient native
buffer and the same zero-copy materialization policy as callWithBuffer
(no scratch pool — reused scratch would force an extra copy for ≥32 KiB).
Implementation
StreamBufferFetchResult? streamCallWithBuffer(
StreamBufferCallback fn, {
int? maxSize,
int? initialSize,
bool? allowZeroCopy,
}) {
final limit = maxSize ?? maxBufferSize;
final size = initialSize ?? initialBufferSize;
final zeroCopy = allowZeroCopy ?? isZeroCopyResultBufferAvailable;
return _streamCallWithTransientBuffer(
fn,
limit: limit,
initialSize: size,
allowZeroCopy: zeroCopy,
);
}