NPRPC docs

class NPRPCStreamReader

Swift

class NPRPCStreamReader<T> where T : Sendable

The receiving end of a stream: what a proxy's server_stream method returns, and what a servant's client_stream method receives.

Iterate it with for try await; the loop ends when the producer finishes and throws if it fails:

for try await post in try blog.feed(limit: 10) {
    show(post)
}

Flow control is automatic: the reader grants the producer more credits as items are consumed.

nprpc_swift/Sources/NPRPC/StreamReader.swift:79

Constructors

init(streamId: UInt64, buffer: FlatBuffer, deserializer: @escaping (UnsafeRawPointer, Int) -> T)

Created by generated code; deserializer decodes one chunk's payload.

nprpc_swift/Sources/NPRPC/StreamReader.swift:103

Properties

var asyncStream: AsyncThrowingStream<T, Error> { get }

Get the underlying async stream for iteration

nprpc_swift/Sources/NPRPC/StreamReader.swift:116

var onFirstAccess: (@Sendable () -> Void)?

Fired once when the consumer first enters next() (before awaiting a chunk). Used by stream-init exception probing on the servant side.

nprpc_swift/Sources/NPRPC/StreamReader.swift:98

Methods

func cancel()

Cancel the stream

nprpc_swift/Sources/NPRPC/StreamReader.swift:193

func makeAsyncIterator() -> WindowedIterator

for try await support.

nprpc_swift/Sources/NPRPC/StreamReader.swift:121

Type aliases

typealias Element = T

The item type.

nprpc_swift/Sources/NPRPC/StreamReader.swift:81

Types