iostream.blob.writeblob
Writes the given blob and returns the number of bytes written
from "iostream" import blob
let src = blob(0)
src.writestring("ammo")
let dst = blob(0)
println("dst.writeblob(src) =", dst.writeblob(src))
println("dst.as_string() =", dst.as_string())Output:
dst.writeblob(src) = 4
dst.as_string() = ammoParameters
blob | instance | the source blob; all of it is written |
Return value
See iostream.stream.writeblob for the generic contract.
Notes
Writing past the current len grows this blob to fit, the same as writen; it is never an error to write more than currently fits.
Example
from "iostream" import blob
let src = blob(3)
src[0] = 7; src[1] = 8; src[2] = 9
let dst = blob(0) // empty: writing to it must grow it
println("dst.writeblob(src) =", dst.writeblob(src))
println("dst.len() =", dst.len())
println("dst[0], dst[1], dst[2] =", $"{dst[0]},{dst[1]},{dst[2]}")Output:
dst.writeblob(src) = 3
dst.len() = 3
dst[0], dst[1], dst[2] = 7,8,9See also
writeblob | Writes the given blob and returns the number of bytes written |
readblob | Reads up to size bytes and returns them as a blob |
writestring | Writes the string and returns the number of characters written |
| blob | class index |