package octez-proto-libs

  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 slices 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 : _ Data_encoding.Encoding.t -> slicer_state -> (slice list, Data_encoding__.Binary_error_types.read_error) 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 : _ Data_encoding.Encoding.t -> slicer_state -> slice list option
val slice_exn : _ Data_encoding.Encoding.t -> slicer_state -> slice list
val slice_string : _ Data_encoding.Encoding.t -> string -> (slice list, read_error) 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 : _ Data_encoding.Encoding.t -> string -> slice list option
val slice_string_exn : _ Data_encoding.Encoding.t -> string -> slice list
val slice_bytes : _ Data_encoding.Encoding.t -> bytes -> (slice list, read_error) result
val slice_bytes_opt : _ Data_encoding.Encoding.t -> bytes -> slice list option
val slice_bytes_exn : _ Data_encoding.Encoding.t -> bytes -> slice list
OCaml

Innovation. Community. Security.