123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990(* Copyright (C) 2022--2023 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.
*)moduletypeDRIVER=sigtype+'afibertype(+'a,+'err)streamtypeswitchtypestdenvmoduletypeCONNECTION=Caqti_connection_sig.Swithtype'afiber:='afiberandtype('a,'err)stream:=('a,'err)streamvaldriver_info:Caqti_driver_info.tvalconnect:sw:switch->stdenv:stdenv->?env:(Caqti_driver_info.t->string->Caqti_query.t)->tweaks_version:int*int->Uri.t->((moduleCONNECTION),[>Caqti_error.connect])resultfiberendmoduletypeDRIVER_FUNCTOR=functor(System:System_sig.S)->DRIVERwithtype'afiber:='aSystem.Fiber.tandtype('a,'err)stream:=('a,'err)System.Stream.tandtypeswitch:=System.Switch.tandtypestdenv:=System.stdenvletdrivers=Hashtbl.create5letregisterschemep=Hashtbl.adddriversschemepmoduletypeS=sigtype+'afibertype(+'a,+'e)streamtypeswitchtypestdenvmoduletypeCONNECTION=Caqti_connection_sig.Swithtype'afiber:='afiberandtype('a,'e)stream:=('a,'e)streammoduletypeDRIVER=DRIVERwithtype'afiber:='afiberandtype('a,'e)stream:=('a,'e)streamandtypeswitch:=switchandtypestdenv:=stdenvvalload_driver:uri:Uri.t->string->((moduleDRIVER),[>Caqti_error.load])resultendmoduleMake(System:System_sig.S)=structmoduletypeDRIVER=DRIVERwithtype'afiber:='aSystem.Fiber.tandtype('a,'e)stream:=('a,'e)System.Stream.tandtypeswitch:=System.Switch.tandtypestdenv:=System.stdenvmoduletypeCONNECTION=Caqti_connection_sig.Swithtype'afiber:='aSystem.Fiber.tandtype('a,'e)stream:=('a,'e)System.Stream.tletload_driver~urischeme=(matchHashtbl.find_optdriversschemewith|None->letmsg="Driver not found; UNIX drivers not considered."inError(Caqti_error.load_failed~uri(Caqti_error.Msgmsg))|Somemake_driver->letmoduleMake_driver=(valmake_driver:DRIVER_FUNCTOR)inletmoduleDriver=Make_driver(System)inOk(moduleDriver:DRIVER))end