package capnp

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

FragmentBuffer provides efficient management of large numbers of string fragments. Reading a large message from a pipe, for example, may lead to construction of large numbers of fragments which need to parsed and refactored into a list of message segments. Use of the FragmentBuffer helps to avoid the inefficient construction of intermediate strings.

type t
val empty : unit -> t

Create a new, empty fragment buffer.

val of_string : string -> t

Create a new fragment buffer containing the contents of the string.

val byte_count : t -> int

Get the number of bytes stored in the fragment buffer.

val add_fragment : t -> string -> unit

Add a fragment to the back of the fragment buffer.

val remove_exact : t -> int -> string option

Remove a specific number of bytes from the front of the fragment buffer.

val remove_at_least : t -> int -> string option

Remove at least the specified number of bytes from the front of the fragment buffer. This is a less expensive operation than remove_exact.

val peek_exact : t -> int -> string option

Examine a specific number of bytes from the front of the fragment buffer, without removing the data.

val unremove : t -> string -> unit

Return some bytes to the front of the fragment buffer.

OCaml

Innovation. Community. Security.