Module Olm.Helpers
module YoJs = Yojson_helpers
module ResultInfix : sig ... end
val allocate_buf : ?finalise:(char Ctypes.ptr -> unit) -> int -> char Ctypes.ptr
allocate_buf ?finalise n_bytes
Create char buffer of size
n_bytes
with optionalfinalise
for the garbage collector.
val finaliser : 'a Ctypes.typ -> ('a Ctypes_static.ptr -> 'b) -> char Ctypes_static.ptr -> unit
finaliser t clear char_ptr
Create a finalisation closure (accepting the
char_ptr
to finalise) fort
, usingclear
. Simply performing the necessary coersion between the originally allocated char buffer and the actual typet
.
val allocate_bytes_void : int -> unit Ctypes.ptr
allocate_bytes_void n_bytes
Allocate
n_bytes
of memory and return a void pointer to it.
val size_of_int : int -> Unsigned.size_t
val size_to_int : Unsigned.size_t -> int
val olm_error : int
olm_error
Integer representation of the return value of
C.Funcs.error
(olm_error () in the C headers.). Return values of libolm functions are checked against this to determine whether an error occurred and thelast_error
of the relevant Olm object needs to be checked.
val size_to_result : Unsigned.size_t -> (int, [> `OlmError ]) Core.result
size_to_result size
Maps libolm return
size
to an integer in the Result monad if not equal toolm_error
, otherwise`OlmError
.
val zero_bytes : 'a Ctypes.typ -> length:int -> 'a Ctypes_static.ptr -> unit
zero_bytes ctyp ~length p
Zero out the memory backing the
p
of sizelength
and typectyp
.
val string_of_ptr : 'a Ctypes.typ -> length:int -> 'a Ctypes_static.ptr -> string
string_of_ptr ctyp ~length p
Map
p
of sizelength
and typectyp
to string.
val string_of_ptr_clr : 'a Ctypes.typ -> length:int -> 'a Ctypes_static.ptr -> string
string_of_ptr_clr ctyp ~length p
string_of_ptr
, but runzero_bytes
onp
afterwards.
val string_to_ptr : 'a Ctypes.typ -> string -> 'a Ctypes_static.ptr
string_to_ptr ctyp s
Map
s
to a pointer of typectyp
.
val string_to_sized_buff : 'a Ctypes.typ -> string -> 'a Ctypes_static.ptr * Unsigned.size_t
string_to_sized_buff ctyp s
string_of_ptr
, but also returning the size of the resulting buffer along with the pointer in a tuple.
val non_empty_string : ?label:string -> string -> (string, [> `ValueError of string ]) Core.result
non_empty_string ?label s
Map
s
into the Result monad, returning a`ValueError msg
if it is empty. Iflabel
is provided, it is added to the error message to make it more specific.
module UTF8 : sig ... end