package piaf

  1. Overview
  2. Docs
type t
type length = [
  1. | `Fixed of Int64.t
  2. | `Chunked
  3. | `Error of [ `Bad_request | `Bad_gateway | `Internal_server_error ]
  4. | `Unknown
  5. | `Close_delimited
]
val length : t -> length
val empty : t
val of_stream : ?length:length -> Bigstringaf.t IOVec.t Stream.t -> t
val of_string_stream : ?length:length -> string Stream.t -> t
val of_string : string -> t
val of_bigstring : ?off:int -> ?len:int -> Bigstringaf.t -> t
val sendfile : ?length:length -> string -> (t, [> Error.common ]) result
val to_string : t -> (string, [> Error.t ]) result
val drain : t -> (unit, [> Error.t ]) result
val is_closed : t -> bool
val closed : t -> (unit, [> Error.t ]) result
val when_closed : f:((unit, [> Error.t ]) result -> unit) -> t -> unit
val is_errored : t -> bool

Destruction

val to_list : t -> Bigstringaf.t IOVec.t list
val to_string_list : t -> string list

Traversal

val fold : f:('a -> Bigstringaf.t IOVec.t -> 'a) -> init:'a -> t -> ('a, [> Error.t ]) result
val fold_string : f:('a -> string -> 'a) -> init:'a -> t -> ('a, [> Error.t ]) result
val iter : f:(Bigstringaf.t IOVec.t -> unit) -> t -> (unit, [> Error.t ]) result
val iter_p : sw:Eio.Switch.t -> f:(Bigstringaf.t IOVec.t -> unit) -> t -> (unit, [> Error.t ]) result
val iter_string : f:(string -> unit) -> t -> (unit, [> Error.t ]) result
val iter_string_p : sw:Eio.Switch.t -> f:(string -> unit) -> t -> (unit, [> Error.t ]) result

Conversion to Stream.t

The functions below convert a Piaf.Body.t to a Stream.t. These functions should be used sparingly, and only when interacting with other APIs that require their argument to be a Lwt_stream.t.

These functions return a tuple of two elements. In addition to returning a Lwt_stream.t, the tuple's second element is a promise that will sleep until the stream is consumed (and closed). This promise will resolve to Ok () if the body was successfully transferred from the peer; otherwise, it will return Error error with an error of type Error.t detailing the failure that caused the body to not have been fully transferred from the peer.

val to_stream : t -> Bigstringaf.t IOVec.t Stream.t
val to_string_stream : t -> string Stream.t
OCaml

Innovation. Community. Security.