Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file system_sig.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206(* Copyright (C) 2022--2025 Petter A. Urkedal <paurkedal@gmail.com>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version, with the LGPL-3.0 Linking Exception.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* and the LGPL-3.0 Linking Exception along with this library. If not, see
* <http://www.gnu.org/licenses/> and <https://spdx.org>, respectively.
*)(** Signature for concurrency model and OS-calls.
This is the common part of the signature declarning system dependencies.
Driver which depend on features from the unix library will also need
{!Caqti_platform_unix.System_sig.S}.
*)moduletypeFIBER=sigtype+'at(** A concurrency monad with an optional failure monad, or just the identity
type constructor for blocking operation. *)moduleInfix:sigval(>>=):'at->('a->'bt)->'bt(** Bind operation of the concurrency monad. *)val(>|=):'at->('a->'b)->'bt(** Map operation of the concurrency monad. *)endvalreturn:'a->'at(** Return operation of the concurrency monad. *)valcatch:(unit->'at)->(exn->'at)->'atvalfinally:(unit->'at)->(unit->unitt)->'at(** [finally f g] runs [f ()] and then runs [g ()] whether the former
finished, failed with an exception, or failed with a monadic failure. *)valcleanup:(unit->'at)->(unit->unitt)->'at(** [cleanup f g] runs [f ()] and then runs [g ()] and re-raise the failure if
and only if [f ()] failed with an exception or a monadic failure. *)endmoduletypeSEQUENCER=sigtype'afibertype'atvalcreate:'a->'atvalenqueue:'at->('a->'bfiber)->'bfiberendmoduletypeCORE=sigmoduleFiber:FIBERtypestdenv(** Type of an extra argument to connect functions used to pass through the
network stack in Mirage and stdenv in EIO. This is eliminated at the
service API where not needed. *)(** A module used by EIO to handle cleanup tasks; unit for other platforms. *)moduleSwitch:sigtypettypehookvalrun:(t->'aFiber.t)->'aFiber.tvalcheck:t->unitvalon_release_cancellable:t->(unit->unitFiber.t)->hookvalremove_hook:hook->unitendvalasync:sw:Switch.t->(unit->unitFiber.t)->unit(** [async f] runs [f ()] asynchroneously if possible, else immediately. *)moduleMutex:sigtypetvalcreate:unit->tvallock:t->unitFiber.tvalunlock:t->unitendmoduleCondition:sigtypetvalcreate:unit->tvalwait:t->Mutex.t->unitFiber.tvalsignal:t->unitendmoduleLog:sigtype'alog=('a,unitFiber.t)Logs.msgf->unitFiber.tvalerr:?src:Logs.src->'alogvalwarn:?src:Logs.src->'alogvalinfo:?src:Logs.src->'alogvaldebug:?src:Logs.src->'alogendmoduleStream:Caqti_stream_sig.Swithtype'afiber:='aFiber.tmoduleSequencer:SEQUENCERwithtype'afiber:='aFiber.tendmoduletypeSOCKET_OPS=sigtype'afibertypet(* These are currently only used by PGX. Despite the flush, it PGX is doing
* it's own buffering, so unbuffered should be okay. output_char and
* input_char are only used for the packet header. *)valoutput_char:t->char->unitfibervaloutput_string:t->string->unitfibervalflush:t->unitfibervalinput_char:t->charfibervalreally_input:t->Bytes.t->int->int->unitfibervalclose:t->unitfiberendmoduletypeTLS_PROVIDER=sigtype'afibertypetcp_flowtypetls_flowtypetls_configvaltls_config_key:tls_configoptionCaqti_connect_config.keyvalstart_tls:config:tls_config->?host:[`host]Domain_name.t->tcp_flow->(tls_flow,Caqti_error.msg)resultfiberendmoduletypeNET=sigtype'afibertypeswitchtypestdenvmoduleSockaddr:sigtypetvalunix:string->tvaltcp:Ipaddr.t*int->tendvalgetaddrinfo:stdenv:stdenv->[`host]Domain_name.t->int->(Sockaddr.tlist,[>`Msgofstring])resultfiber(** This should be a specialized version of getaddrinfo, which only returns
entries which is expected to work with the corresponding connect on the
platform implementing this interface. In particular:
- The family can be IPv4 or IPv6, where supported, and this must be
encoded in the {!Sockaddr.t}.
- The socket type is restricted to STREAM.
- The protocol is assumed to be selected automatically from address
family, given the socket type restriction.
All returned values are TCP destinations. If a distinction can be made,
an empty list indicates that the address has no DNS entries, while an
error return indicates that an appropriate DNS server could not be
queried. *)valconvert_io_exception:exn->Caqti_error.msgoption(** If the read and write operations in Socket raise exceptions other than
{!End_of_file} and {!Failure}, this function is used to intercept them. *)(** A socket with input and output channels and dedicated IO functions. This
bundling is done to support the various APIs involved for networking and
StartTLS. *)moduleSocket:SOCKET_OPSwithtype'afiber:='afibertypetcp_flowtypetls_flowvalconnect_tcp:sw:switch->stdenv:stdenv->Sockaddr.t->(Socket.t,Caqti_error.msg)resultfibervaltcp_flow_of_socket:Socket.t->tcp_flowoptionvalsocket_of_tls_flow:sw:switch->tls_flow->Socket.tmoduletypeTLS_PROVIDER=TLS_PROVIDERwithtype'afiber:='afiberandtypetcp_flow:=tcp_flowandtypetls_flow:=tls_flowvalregister_tls_provider:(moduleTLS_PROVIDER)->unitvaltls_providers:Caqti_connect_config.t->(moduleTLS_PROVIDER)listendmoduletypeS=sigincludeCOREmoduleNet:NETwithtype'afiber:='aFiber.tandtypeswitch:=Switch.tandtypestdenv:=stdenvend