package mirage-channel

  1. Overview
  2. Docs
Buffered channels for MirageOS FLOW types

Install

Dune Dependency

Authors

Maintainers

Sources

mirage-channel-5.0.0.tbz
sha256=2863bf7c8944f8d08052751e32572701bac2c5a4aa35569af61f0a3b83f25389
sha512=cd4569d7d4d08de3b2565c72eeba2c0e1910664c79f971044d4f94c126aa2aeaac89925fb7f48b321a12517879c21eb998ad3d2551831f838cd64268f50e3877

Description

Channels are buffered reader/writers built on top of unbuffered FLOW implementations.

Example:

module Channel = Channel.Make(Flow)
...
Channel.read_exactly ~len:16 t
>>= fun bufs -> (* read header of message *)
let payload_length = Cstruct.(LE.get_uint16 (concat bufs) 0) in
Channel.read_exactly ~len:payload_length t
>>= fun bufs -> (* payload of message *)

(* process message *)

Channel.write_buffer t header;
Channel.write_buffer t payload;
Channel.flush t
>>= fun () ->

mirage-channel is distributed under the ISC license.

Tags

org:mirage

Published: 02 Jun 2025

README

mirage-channel — Buffered channels for MirageOS FLOW types

v5.0.0

Channels are buffered reader/writers built on top of unbuffered FLOW implementations.

Example:

module Channel = Channel.Make(Flow)
...
Channel.read_exactly ~len:16 t >>= function
| Error read_error
| Ok `Eof -> ...
| Ok `Data bufs -> (* read header of message *)
  let payload_length = Cstruct.(LE.get_uint16 (concat bufs) 0) in
  Channel.read_exactly ~len:payload_length t >>= function
  | Ok `Data bufs -> (* payload of message *)
  | Ok `Eof -> ...
  | Error read_error
(* process message *)

Channel.write_buffer t header;
Channel.write_buffer t payload;
Channel.flush t >>= function
| Error write_error -> ...
| Ok () -> ...

mirage-channel is distributed under the ISC license.

Installation

mirage-channel can be installed with opam:

opam install mirage-channel

If you don't use opam consult the opam file for build instructions.

Documentation

The documentation and API reference is automatically generated by ocamldoc from the interfaces. It can be consulted online and there is a generated version in the doc directory of the distribution.

Sample programs

If you installed mirage-channel with opam sample programs are located in the directory opam config var channel:doc.

In the distribution sample programs and tests are located in the test directory of the distribution. They can be built with:

dune runtest

Dependencies (7)

  1. fmt >= "0.8.7"
  2. logs
  3. cstruct >= "6.0.0"
  4. lwt >= "4.0.0"
  5. mirage-flow >= "4.0.0"
  6. dune >= "1.0"
  7. ocaml >= "4.07.0"

Dev Dependencies (2)

  1. mirage-flow-combinators with-test & >= "2.0.0"
  2. alcotest with-test

Conflicts (1)

  1. tcpip < "3.0.0"
OCaml

Innovation. Community. Security.