package data-encoding

  1. Overview
  2. Docs
type slice = {
  1. name : string;
  2. value : string;
  3. pretty_printed : string;
}

A slice is a part of a binary representation of some data. The concatenation of multiple slice represents the whole data.

type slicer_state
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 b offset length slices the data represented by the length bytes in b starting at index offset.

If e does not correctly describe the given bytes (i.e., if read would fail on equivalent parameters) then it returns Error.

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 buffer.

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
OCaml

Innovation. Community. Security.