tezos-stdlib
Library
Module
Module type
Parameter
Class
Class type
val create : ?maxlength:int -> ?fresh_buf_size:int -> unit -> t
create ?maxlength ?fresh_buf_size ()
creates a buffer of size maxlength
(by default 32
kb). If the buffer is full, a buffer of size fresh_buf_size
is allocated (by default 2
kb).
write ~maxlen ~fill_using buffer
calls fill_using buf offset
maxlen
where buf
is a buffer that has room for maxlen
data starting from offset
.
Assumes that fill_using
returns the exact amount of written bytes.
Behaviour is unspecified if fill_using
writes more than maxlen
data or lies on the number of written bytes.
It returns a data descriptor for the supposedly written chunk.
read data ~len ~into:buf buffer ~offset
copies len
data from the data
chunk into buf
. If len
is not provided, it copies all the data. If len
is less than the amount of data available, it returns a new handler of the remainder.
- Assumes that
data
has been produced by awrite
attempt inbuffer
. - Assumes that
len
is less thanlength data
.
val length : data -> int
length data
returns the amount of available bytes in data