package eio

  1. Overview
  2. Docs
Effect-based direct-style IO API for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

eio-0.10.tbz
sha256=390f7814507b8133d6c25e3a67a742d731c7ca66252b287b1fb0e3ad4d10eecc
sha512=9c0c9088b178df9799aaae9deb803a802228f1329cbe452479c90e80a13985d9c364ea86ee14e4e759133940f9f6065c7e8ece509d176fb1e347c5320f00a494

doc/src/eio.unix/eio_unix.ml.html

Source file eio_unix.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
[@@@alert "-unstable"]

module Fd = Fd
module Resource = Resource
module Private = Private

include Types
type socket = Net.stream_socket

let await_readable = Private.await_readable
let await_writable = Private.await_writable
let pipe = Private.pipe

type Eio.Exn.Backend.t += Unix_error of Unix.error * string * string
let () =
  Eio.Exn.Backend.register_pp (fun f -> function
      | Unix_error (code, name, arg) -> Fmt.pf f "Unix_error (%s, %S, %S)" (Unix.error_message code) name arg; true
      | _ -> false
    )

let sleep d =
  Eio.Time.Mono.sleep (Effect.perform Private.Get_monotonic_clock) d

let run_in_systhread = Private.run_in_systhread

(* Deprecated *)
module FD = struct
  let peek t = Fd.use_exn "peek" (Resource.fd t) Fun.id

  let peek_opt t =
    match Resource.fd_opt t with
    | None -> None
    | Some fd -> Some (Fd.use_exn "peek_opt" fd Fun.id)

  let take t = Fd.remove (Resource.fd t) |> Option.get

  let take_opt t =
    match Resource.fd_opt t with
    | None -> None
    | Some fd -> Fd.remove fd

  let as_socket = Net.import_socket_stream
end

module Ipaddr = Net.Ipaddr

let socketpair ~sw ?domain ?(ty=Unix.SOCK_STREAM) ?protocol () =
  assert (ty = Unix.SOCK_STREAM);
  Net.socketpair_stream ~sw ?domain ?protocol ()

module Ctf = Ctf_unix

let getnameinfo = Net.getnameinfo

module Process = Process
module Net = Net

module Stdenv = struct
  type base = <
    stdin  : source;
    stdout : sink;
    stderr : sink;
    net : Eio.Net.t;
    domain_mgr : Eio.Domain_manager.t;
    process_mgr : Process.mgr;
    clock : Eio.Time.clock;
    mono_clock : Eio.Time.Mono.t;
    fs : Eio.Fs.dir Eio.Path.t;
    cwd : Eio.Fs.dir Eio.Path.t;
    secure_random : Eio.Flow.source;
    debug : Eio.Debug.t;
  >
end
OCaml

Innovation. Community. Security.