Module Pkt_line.Encoder

type encoder = {
  1. payload : Stdlib.Bytes.t;
  2. mutable pos : int;
}
val io_buffer_size : int
val create : unit -> encoder
type error = [
  1. | `No_enough_space
]
val pp_error : error Fmt.t
type 'err state =
  1. | Write of {
    1. buffer : string;
    2. off : int;
    3. len : int;
    4. continue : int -> 'err state;
    }
  2. | Error of 'err
  3. | Done
val safe : (encoder -> [> error ] as 'err state) -> encoder -> 'err state
val flush : (encoder -> [> error ] as 'err state) -> encoder -> 'err state
val write : encoder -> string -> unit

write e s writes s into e.payload if there is enough space, i.e., Bytes.length e e.payload - e.pos > String.length s. Otherwise, raises.

  • raises Leave

    `No_enough_space if String.length

val blit : encoder -> buf:string -> off:int -> len:int -> unit