package bytebuffer

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

Module BytebufferSource

Extensible buffers using bigstrings.

Sourcetype t
Sourcemodule View : sig ... end
Sourceval create : int -> t

create size returns a new empty bytebuffer. This function will allocate a new bigstring of size size. The bytebuffer will be resized automatically if attempting to add more than size characters to the bytebuffer.

Sourceval of_bigstring : bigstring -> t

of_bigstring creates a new bytebuffer and uses the user provided bigstring as the backing store.

Sourceval contents : t -> bigstring

contents returns a copy of the current contents of the bytebuffer.

Sourceval contents_string : t -> string

contents_string is the same as contents except it returns the copy as a string.

Sourceval length : t -> int

length returns the number of characters in the bytebuffer.

Sourceval capacity : t -> int

capacity is the size of the underlying bigstring.

Sourceval clear : t -> unit

clear empties the bytebuffer.

Sourceval reset : t -> unit

reset clears the bytebuffer and resets the underlying bigstring to the initial bigstring used during create.

Sourceval add_char : t -> char -> unit

add_char appends a charater at the end of the bytebuffer.

Sourceval add_string : t -> string -> unit

add_string appends a string at the end of the bytebuffer.

Sourceval add_bigstring : t -> ?pos:int -> ?len:int -> bigstring -> unit

add_bigstring appends a bigstring at the end of the bytebuffer.

Sourceval fill : t -> View.t

fill returns a view into the buffer's underlying bigstring that can be used to blit bytes directly into the buffer. This can be useful to directly read content into the buffer.

Sourceval consume : t -> View.t

consume returns a view into the buffer's underlying bigstring that can be used to blit bytes from the buffer. This can be useful to consume bytes from the buffer and blit them directly for I/O operations.

Sourceval addf : t -> ('a, Format.formatter, unit, unit) format4 -> 'a
Sourceval index : ?pos:int -> ?len:int -> char -> t -> int option

index returns the index of the character if it exists within the buffer.

Sourceval unsafe_index : ?pos:int -> ?len:int -> char -> t -> int

unsafe_index is similar to index but instead of options it returns a negative integer if the character isn't present in the buffer.

Sourceval drop : t -> int -> unit

drop n deletes the first n bytes from the buffer.

OCaml

Innovation. Community. Security.