Module Core__Iobuf.Expert
The Expert module is for building efficient out-of-module Iobuf abstractions.
val buf : (_, _) t -> Core__.Import.Bigstring.tThese accessors will not allocate, and are mainly here to assist in building low-cost syscall wrappers.
One must be careful to avoid writing out of the limits (between
lo_minandhi_max) of thebuf. Doing so would violate the invariants of the parentIobuf.
val hi_max : (_, _) t -> intval hi : (_, _) t -> intval lo : (_, _) t -> intval lo_min : (_, _) t -> intval set_buf : (_, _) t -> Core__.Import.Bigstring.t -> unitThese setters directly set fields in
twithout checking any invariants.
val set_hi_max : (_, _) t -> int -> unitval set_hi : (_, _) t -> int -> unitval set_lo : (_, _) t -> int -> unitval set_lo_min : (_, _) t -> int -> unitto_bigstring_shared tandto_iobuf_shared tallocate new wrappers around the storage ofbuf t, relative tot's current bounds.These operations allow access outside the bounds and limits of
t, and without respect to its read/write access. Be careful not to violatet's invariants.
val reinitialize_of_bigstring : (_, _) t -> pos:int -> len:int -> Core__.Import.Bigstring.t -> unitreinitialize_of_bigstring t bigstringreinitializestwith backingbigstring, and the window and limits specified starting atposand of lengthlen.
val set_bounds_and_buffer : src:('data, _) t -> dst:('data, seek) t -> unitThese versions of
set_bounds_and_bufferallow~srcto be read-only.~dstwill be writable through~srcaliases even though the type does not reflect this!
val set_bounds_and_buffer_sub : pos:int -> len:int -> src:('data, _) t -> dst:('data, seek) t -> unitval protect_window : ('rw, _) t -> f:(('rw, seek) t -> 'a) -> 'aSimilar to
protect_window_and_bounds, but does not save/restore the buffer or bounds. Mixing this with functions likeset_bounds_and_bufferornarrowis unsafe; you should not modify anyything but the window insidef.
val fillf_float : (Core__.Import.read_write, seek) t -> c_format:string -> float -> [ `Ok | `Truncated | `Format_error ]fillf_float t ~c_format floatattempts to fill a string representation of a float into an iobuf at the current position. The representation is specified by standard Cprintfformatting codes.The highest available byte of the window is unusable and will be set to 0 in the case that a properly formatted string would otherwise fully fill the window.
If there is enough room in (window - 1) to format the float as specified then
`Okis returned and the window is advanced past the written bytes.If there is not enough room in (window - 1) to format as specified then
`Truncatedis returned.If C
snprintfindicates a format error then`Format_erroris returned.Operation is unsafe if a format code not intended for a double precision float is used (e.g., %s) or if more than one format specifier is provided, etc.