package capnp

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

Module Runtime.FragmentBufferSource

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.

Sourcetype t
Sourceval empty : unit -> t

Create a new, empty fragment buffer.

Sourceval of_string : string -> t

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

Sourceval byte_count : t -> int

Get the number of bytes stored in the fragment buffer.

Sourceval add_fragment : t -> string -> unit

Add a fragment to the back of the fragment buffer.

Sourceval remove_exact : t -> int -> string option

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

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

Sourceval peek_exact : t -> int -> string option

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

Sourceval unremove : t -> string -> unit

Return some bytes to the front of the fragment buffer.

OCaml

Innovation. Community. Security.