iostream.blob.eos
Returns non-null if the stream is at end-of-stream
from "iostream" import blob
let cargo = blob(4)
cargo.readn('i') // consumes all 4 bytes
println("cargo.eos() =", cargo.eos())Output:
cargo.eos() = 1Return value
See iostream.stream.eos for the generic contract.
Notes
For a blob this is tell() == len(). Both change often on a blob - len grows on a write past the end, tell moves on every read, write or seek - so eos reflects the current state of both, not a sticky flag.
Example
from "iostream" import blob
let b = blob(2)
println("b.eos() at start =", b.eos()) // cursor 0, len 2: not at the end
b.readn('b')
println("b.eos() after 1 readn('b') =", b.eos()) // cursor 1, len 2: still not there
b.readn('b')
println("b.eos() after 2 readn('b') =", b.eos()) // cursor 2, len 2: now at the end
b.writen(9, 'b') // writing past the end grows len, so eos flips back
println("b.eos() after writen past end =", b.eos())Output:
b.eos() at start = null
b.eos() after 1 readn('b') = null
b.eos() after 2 readn('b') = 1
b.eos() after writen past end = 1See also
eos | Returns non-null if the stream is at end-of-stream |
tell | Returns the current stream position |
len | Returns the stream length |
| blob | class index |