Library
Module
Module type
Parameter
Class
Class type
Blob
are lists of cstructs, with constant-time append operations. This is optimized to store large files where contents is always appended (e.g. log files).
val empty : t
The empty blob.
write t ~offset data
is the blob t
overwritten with data
at offset
. The new blob is extended and zero-filled as necessary. If offset = len t
then this is very fast.
val len : t -> int64
truncate t l
is a blob of length l
. If l <= len t
then it is the prefix of t
of length l
. If l > len t
then it is t
followed by enough zero bytes to make up the length. Return an error if the requested length is negative.
val read :
t ->
offset:int64 ->
count:int ->
(Cstruct.t, Vfs.Error.t) Pervasives.result
read t ~offset ~count
is the count
bytes in t
starting at offset
. If the blob is not long enough to return count
bytes, then it returns as many as possible. Return an error if offset <
0 || offset > len t
.
val ro_cstruct : Cstruct.t -> t
ro_cstruct c
is a blob containing the data c
. Note that we take a reference to c
rather than copying, so c
MUST NOT be modified after this call. c
may also be shared with modified versions of the resulting blob.
val to_ro_cstruct : t -> Cstruct.t
to_ro_cstruct t
is a read-only Cstruct with the same data as t
. DO NOT modify this - it may corrupt the blob or other blobs sharing data with this one if you do.
val string : string -> t
string s
is a blob containing the same data as s
.
val to_string : t -> string
to_string t
is a string containing the same data as t
.