Block device abstraction for OCaml 5 with Eio direct-style I/O and Bytesrw integration
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-block: enable MDX on lib/block.mli, fix broken doc example

Run mdx on lib/block.mli so the {[ ... ]} odoc block now type-checks.

The example called `Block.of_file ~sw env#fs "disk.img" ~sector_size:512`,
but the real signature takes a single `_ Eio.Path.t` (not separate fs +
filename) and ends with `unit -> t` (the example was missing the
trailing `()`). Also dropped the trailing `(* ... *)` placeholder by
matching on `Block.read`'s `result` and printing the sector length on
success / a stderr error on failure.

Wrapped the whole thing in `let run () =` so the file open does not
materialise on disk at mdx test time.

+13 -3
+9 -3
lib/block.mli
··· 15 15 granularity. 16 16 17 17 {[ 18 + let run () = 18 19 Eio_main.run @@ fun env -> 19 20 Eio.Switch.run @@ fun sw -> 20 - let blk = Block.of_file ~sw env#fs "disk.img" ~sector_size:512 in 21 + let fs = Eio.Stdenv.fs env in 22 + let blk = 23 + Block.of_file ~sw Eio.Path.(fs / "disk.img") ~sector_size:512 () 24 + in 21 25 let info = Block.info blk in 22 26 Printf.printf "Sectors: %Ld, Size: %d\n" info.sectors info.sector_size; 23 - let data = Block.read blk 0L in 24 - (* ... *) 27 + match Block.read blk 0L with 28 + | Ok data -> 29 + Printf.printf "first sector: %d bytes\n" (String.length data) 30 + | Error _ -> Printf.eprintf "read failed\n" 25 31 ]} 26 32 27 33 {1 Types} *)
+4
lib/dune
··· 2 2 (name block) 3 3 (public_name block) 4 4 (libraries eio bytesrw cstruct fmt)) 5 + 6 + (mdx 7 + (files block.mli) 8 + (libraries block eio eio.core eio.unix eio_main))