Module Huri

URI Buf_write serialization for the requests library.

This module provides efficient Eio.Buf_write serialization for Uri.t values. For all other URI operations, use the uri opam library directly.

Usage

  (* Use Uri for parsing and manipulation *)
  let uri = Uri.of_string "https://example.com/path" in
  let host = Uri.host uri in

  (* Use Huri.write for efficient serialization to Buf_write *)
  Eio.Buf_write.with_flow flow (fun w ->
    Huri.write w uri
  )

Type Alias

type t = Uri.t

t is an alias for Uri.t. Use the uri library for all operations except Buf_write serialization.

Buf_write Serialization

val write : Eio.Buf_write.t -> t -> unit

write w uri writes uri directly to the buffer w. This is more efficient than Uri.to_string when writing to an I/O sink as it avoids intermediate string allocation.

JSON Codec

val jsont : t Jsont.t

JSON codec for URIs. Encodes as a JSON string.