Yo!
I am happy to announce the next version of the Bytream library, which allows streaming bytes and processing them with low memory allocation. This release includes many important updates.
Changes
-
Now,
Bytreamfor slices uses the Slice library from the Bstr project instead of its own~buffer, ~offset, ~lengthlabeled tuples, which require OCaml version 5.2 or higher;let of_channel ?(io_buffer_size = 4096) ic = let buffer = Bstr.create io_buffer_size in let reader () = match In_channel.input_bigarray ic buffer 0 io_buffer_size with | 0 -> raise End_of_file | len -> Slice_bstr.make ~len buffer in make reader -
Added
bytream.ozstdfor Zstandard compression and decompression via the ozstd library;let output_compressed_string out_stream = let out_stream = Bytream_ozstd.Out.make ~compression_level:3 out_stream in Bytream.Out.output_string out_stream "Cras pulvinar sollicitudin nulla quis tempor."; Bytream.Out.flush out_stream let input_decompressed_line in_stream = let in_stream = Bytream_ozstd.In.make in_stream in Bytream.In.input_line in_stream -
Added
bytream.binfor declarative encoding and decoding bytes via the Bin library;type point = { x : int; y : int } let point = let open Bin in record (fun x y -> { x; y }) |+ field neint16 (fun t -> t.x) |+ field neint16 (fun t -> t.y) |> sealr let _ = (* ... *) let p = Bytream_bin.In.input in_stream point in Bytream_bin.Out.output out_stream point { p with y = p.y * 2 }
Credits
I would like to express my special gratitude to Robur Coop for their libraries (Bstr, Slice, Bin, etc.), which are very closely integrated into my projects such as Bytream, ozstd and other. Thanks!