Iobuf.ExpertThe Expert module is for building efficient out-of-module Iobuf abstractions.
These 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_min and hi_max) of the buf. Doing so would violate the invariants of the parent Iobuf.
val buf : (_, _, Core.Modes.At_locality.global) t @ local -> Core.Bigstring.tval hi_max : (_, _, _) t @ local -> intval hi : (_, _, _) t @ local -> intval lo : (_, _, _) t @ local -> intval lo_min : (_, _, _) t @ local -> intval set_buf : (_, _, _) t @ local -> (Core.Bigstring.t -> unit) @ localThese setters directly set fields in t without checking any invariants.
val set_hi_max : (_, _, _) t @ local -> (int -> unit) @ localval set_hi : (_, _, _) t @ local -> (int -> unit) @ localval set_lo : (_, _, _) t @ local -> (int -> unit) @ localval set_lo_min : (_, _, _) t @ local -> (int -> unit) @ localto_bigstring_shared t and to_iobuf_shared t allocate new wrappers around the storage of buf t, relative to t'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 violate t's invariants.
val reinitialize_of_bigstring :
(_, _, _) t @ local ->
(pos:int ->
(len:int ->
(Core.Bigstring.t ->
unit) @ local) @ local) @ localreinitialize_of_bigstring t bigstring reinitializes t with backing bigstring, and the window and limits specified starting at pos and of length len.
val unsafe_reinitialize :
(_, _, _) t @ local ->
(lo_min:int ->
(lo:int ->
(hi:int ->
(hi_max:int ->
(Core.Bigstring.t ->
unit) @ local) @ local) @ local) @ local) @ localAs reinitialize_of_bigstring but without checking, and requires explicit specification of bounds.
val set_bounds_and_buffer :
src:('data, _, Core.Modes.At_locality.global) t @ local ->
(dst:('data, Iobuf__.Iobuf_type_intf.Definitions.no_seek, _) t @ local ->
unit) @ localThese versions of set_bounds_and_buffer allow ~src to be read-only. ~dst will be writable through ~src aliases even though the type does not reflect this!
val set_bounds_and_buffer_sub :
pos:int ->
len:int ->
src:('data, _, Core.Modes.At_locality.global) t @ local ->
(dst:('data, Iobuf__.Iobuf_type_intf.Definitions.no_seek, _) t @ local ->
unit) @ localval protect_window :
('rw, _, 'loc) t @ local ->
(f:
(('rw, Iobuf__.Iobuf_type_intf.Definitions.no_seek, 'loc) t @ local -> 'a) @ local ->
'a) @ localSimilar to protect_window_bounds_and_buffer, but does not save/restore the buffer or bounds. Mixing this with functions like set_bounds_and_buffer or narrow is unsafe; you should not modify anyything but the window inside f.
val protect_window_global_deprecated :
('rw, _, 'loc) t ->
f:(('rw, Iobuf__.Iobuf_type_intf.Definitions.no_seek, 'loc) t -> 'a) @ local ->
'aAs protect_window but does not enforce that the closure should not let the buffer escape. Letting the buffer escape is dangerous and almost certainly not what you wanted.
val protect_window__local :
'a 'rw 'sk 'loc. ('rw, 'sk, 'loc) t @ local ->
(f:
(('rw, Iobuf__.Iobuf_type_intf.Definitions.no_seek, 'loc) t @ local ->
'a @ local) @ local ->
'a @ local) @ localSimilar to protect_window but returns a local value.
val buf_pos_exn :
(_, _, _) t @ local ->
(pos:int ->
(len:int ->
int) @ local) @ localComputes the position within buf for pos relative to our window. Checks len bytes are available.
val unsafe_buf_pos :
(_, _, _) t @ local ->
(pos:int ->
(len:int ->
int) @ local) @ localAs buf_pos_exn without checks.