package uwt

  1. Overview
  2. Docs
type 'a t = private int

Int_result.t is used instead of 'a result, if a function returns either an error or a non-negative integer (including unit/bool). This way, we can avoid an extra allocation.

type real_int = int
type real_unit = unit
type int = real_int t
type unit = real_unit t
val is_ok : 'a t -> bool
val is_error : 'a t -> bool
val to_int : int -> real_int

will raise Invalid_argument, if is_ok is false

val to_error : 'a t -> error

will raise Invalid_argument, if is_error is false

val plain : 'a t -> real_int
val to_exn : ?name:string -> ?param:string -> 'a t -> exn
val raise_exn : ?name:string -> ?param:string -> 'a t -> 'b

You can use the following values to compare a Int_result.t value with an assumed error, e.g.

let p = Uwt.Stream.try_write t ~buf in
if (p :> int) = Uwt.Int_result.eagain then
  ...
else
  ...

All values are negative integers, but don't make any further assumption about them. Their concrete values can change with any uwt release.

val eagain : int
val e2big : int
val eacces : int
val eaddrinuse : int
val eaddrnotavail : int
val eafnosupport : int
val eai_addrfamily : int
val eai_again : int
val eai_badflags : int
val eai_badhints : int
val eai_canceled : int
val eai_fail : int
val eai_family : int
val eai_memory : int
val eai_nodata : int
val eai_noname : int
val eai_overflow : int
val eai_protocol : int
val eai_service : int
val eai_socktype : int
val ealready : int
val ebadf : int
val ebusy : int
val ecanceled : int
val echarset : int
val econnaborted : int
val econnrefused : int
val econnreset : int
val edestaddrreq : int
val eexist : int
val efault : int
val efbig : int
val ehostunreach : int
val eintr : int
val einval : int
val eio : int
val eisconn : int
val eisdir : int
val eloop : int
val emfile : int
val emsgsize : int
val enametoolong : int
val enetdown : int
val enetunreach : int
val enfile : int
val enobufs : int
val enodev : int
val enoent : int
val enomem : int
val enonet : int
val enoprotoopt : int
val enospc : int
val enosys : int
val enotconn : int
val enotdir : int
val enotempty : int
val enotsock : int
val enotsup : int
val eperm : int
val epipe : int
val eproto : int
val eprotonosupport : int
val eprototype : int
val erange : int
val erofs : int
val eshutdown : int
val espipe : int
val esrch : int
val etimedout : int
val etxtbsy : int
val exdev : int
val unknown : int
val eof : int
val enxio : int
val uwt_efatal : int
OCaml

Innovation. Community. Security.