package httpaf

  1. Overview
  2. Docs

Module Httpaf.BigstringSource

Bigstring

A block of memory allocated on the C heap. Bigstring payloads won't get relocated by the OCaml GC, making it safe to use in blocking system calls without holding the OCaml runtime lock.

For compatiblity with other libraries, Bigstring.t is not abstract.

Sourceval create : int -> t

create len allocates a bigstring of length len.

Sourceval of_string : ?off:int -> ?len:int -> string -> t

of_string ?off ?len str allocates a bigstring and copies the contents of str into it. if off or len are provided, t will only have length len and only the specified range of the string will be copied into it.

Sourceval length : t -> int

length t returns the length of the bigstring.

Sourceval get : t -> int -> char
Sourceval unsafe_get : t -> int -> char

get t n returns the nth byte of t as a char. unsafe_get t n does the same but will not perform bounds checking.

Sourceval set : t -> int -> char -> unit
Sourceval unsafe_set : t -> int -> char -> unit

set t n returns the nth byte of t as a char. unsafe_set t n does the same but will not perform bounds checking.

Sourceval sub : off:int -> ?len:int -> t -> t

sub ~off ?len t returns a sub-view into the bigstring t, specified by off and len. This is a non-copying operation: t and the returned sub-view will share underlying bytes. Modifying one will modify the other.

Sourceval blit : t -> int -> t -> int -> int -> unit
Sourceval blit_from_string : string -> int -> t -> int -> int -> unit
Sourceval blit_from_bytes : Bytes.t -> int -> t -> int -> int -> unit
Sourceval to_string : ?off:int -> ?len:int -> t -> string
OCaml

Innovation. Community. Security.