package shexp
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=ff0e6ed52adf66dc1a1a9c85577dac043a0821feacfab09a5b8bea8f99ff3ba5
md5=13002fde6249703d06ff820906cd96c9
doc/shexp.bigstring-io/Shexp_bigstring_io/Bigstring/index.html
Module Shexp_bigstring_io.Bigstring
Bigstring IO helpers
include module type of struct include Shexp_bigstring.Std.Bigstring end
type t =
(char, Bigarray.int8_unsigned_elt, Bigarray.c_layout) Bigarray.Array1.t
val create : int -> t
val length : t -> int
val blit_string_t :
src:string ->
src_pos:int ->
dst:t ->
dst_pos:int ->
len:int ->
unit
val sub_string : t -> pos:int -> len:int -> string
val index : t -> pos:int -> len:int -> char:char -> int option
val rindex : t -> pos:int -> len:int -> char:char -> int option
Efficiently checks that the range denoted by (pos, len)
is in the range 0..length
. length
is assumed to be >= 0
.
Raises if (pos, len)
denotes a range outside of 0..length
.
val with_temporary : size:int -> f:(t -> 'a) -> 'a
Allocate a bigstring and pass it to f
. The memory allocated for the bigstring is released as soon as f
returns. As such, the bigstring shouldn't be used after f
returns.
This is more efficient than waiting on the garbage collector to release the external memory.
type ('a, 'b) fold_temporary_result =
('a, 'b) Shexp_bigstring.Bigstring.fold_temporary_result =
val fold_temporary :
size:int ->
init:'a ->
f:(t -> 'a -> ('a, 'b) fold_temporary_result) ->
'b
Same as with_temporary
, but allow to resize the bigstring if needed.
If f
returns Resize { new_size; state }
, the bigstring will be resized to the given new size and f
will be called with the new bigstring and state
. The contents of the bigstring up to the min of the old and new sizes is preserved.
val write : Unix.file_descr -> t -> pos:int -> len:int -> int
val read : Unix.file_descr -> t -> pos:int -> len:int -> int
val read_all : Unix.file_descr -> string
val write_all : Unix.file_descr -> string -> unit
val read_exactly : Unix.file_descr -> int -> string
val read_all_interruptible :
?delay:float ->
Unix.file_descr ->
stop:(unit -> bool) ->
read_all_interruptible_result
Same as read_all
except that stop
is called every delay
seconds until it returns true
. In this case returns prematurely the data collected so far.
val fold_lines : Unix.file_descr -> init:'a -> f:('a -> string -> 'a) -> 'a
val fold_chunks :
Unix.file_descr ->
sep:char ->
init:'a ->
f:('a -> string -> 'a) ->
'a