data stream
Asynchronous sequence of T that ends normally or with one error E; source for for await (§10.3, D-2600..).
Example:
fn countdown(n: i64) -> stream<i64> {
var i = n
while i > 0 {
yield i
i -= 1
}
}
fn main() io {
for await x in countdown(3) {
print("{x}")
}
}Output
3 2 1
@builtin("stream") pub(api) data stream<T, E = never>Thread safety. a stream is consumed by one task.
Since. 1.0.0-beta
Methods
pull | () -> Pulled<T, E>Waits for the next element (a suspension point and cancellation point). |
pullWithin | (d: Duration) -> Pulled<T, E>Like pull, but gives up after d with Timeout. |
first | () -> T | E | noneThe next element, the error that ended the stream, or none at its end (await sub.first() in [С V.5], D-6109). |
lagged | () -> u64Elements dropped for this subscription by Broadcast with .DropOldest (0 for every other stream). |
offset | () -> u64Offset of the element delivered last |
seek | (n: u64)Continues at offset n before the first pull |
resumeFrom | (n: u64) -> stream<T, E>resumeFrom(n): the same stream, continuing at offset n (§10.3). |
withOffsets | () -> stream<(u64, T), E>Every element with its offset |
results | () -> stream<T | E>The error of the stream as one more element |
Defined in: std/core/types.oxl:443