Legend:
Library
Module
Module type
Parameter
Class
Class type
Library
Module
Module type
Parameter
Class
Class type
A slice
is a part of a binary representation of some data. The concatenation of multiple slices represents the whole data.
val make_slicer_state :
string ->
offset:int ->
length:int ->
slicer_state option
None
if offset
and length
do not describe a valid substring.
val slice :
_ Encoding.t ->
slicer_state ->
(slice list, Data_encoding__.Binary_error_types.read_error) Stdlib.result
slice e state
slices the data represented by the substring described by state
.
If e
does not correctly describe the given bytes (i.e., if read
would fail on equivalent parameters) then it returns Error
.
Otherwise it returns Ok sl
and String.concat "" (List.map (fun s -> s.value) sl
is byte-for-byte identical to the substring described by state
.
val slice_opt : _ Encoding.t -> slicer_state -> slice list option
val slice_exn : _ Encoding.t -> slicer_state -> slice list
val slice_string :
_ Encoding.t ->
string ->
(slice list, read_error) Stdlib.result
slice_string
slices the whole content of the string.
In other words, slice_string e s
is slice e (Option.get @@ make_slicer_state s 0 (String.length s)
.
val slice_string_opt : _ Encoding.t -> string -> slice list option
val slice_string_exn : _ Encoding.t -> string -> slice list
val slice_bytes :
_ Encoding.t ->
bytes ->
(slice list, read_error) Stdlib.result
val slice_bytes_opt : _ Encoding.t -> bytes -> slice list option
val slice_bytes_exn : _ Encoding.t -> bytes -> slice list