char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
38d7f6c
main
1declare module"ext:core/ops" { 2import type { FileReply } from "ext:file/errors.js" ; 3 4export type NetAddress = 5| { readonly transport :"tcp" ; readonly hostname :string ; readonly port :number } 6| { readonly transport :"unix" ; readonly path :string | null }; 7export interface NetUdpAddress { 8transport :"udp" ; 9hostname :string ; 10port :number ; 11} 12const listenerAddress :unique symbol ; 13export type NetListenerId < A extends NetAddress > = number & { readonly [ listenerAddress ] :A }; 14export type NetConnection < A extends NetAddress = NetAddress > = [ id :number , local :A , remote :A ]; 15export type NetListener < A extends NetAddress = NetAddress > = [ id :NetListenerId < A >, local :A ]; 16export type NetDatagram = [ id :number , local :NetUdpAddress ]; 17export function op_net_listen ( address :NetAddress & { __proto__ ?:null }) :FileReply < NetListener >; 18export function op_net_connect_start ( address :NetAddress & { __proto__ ?:null }) :FileReply < number >; 19export function op_net_connected ( id :number ) :Promise < FileReply < NetConnection >>; 20export function op_net_accept < A extends NetAddress > ( id :NetListenerId < A >) :Promise < FileReply < NetConnection < A >>>; 21export function op_net_read ( args :[ id :number , count :number ]) :Promise < FileReply < Uint8Array < ArrayBuffer > | null >>; 22export function op_net_write ( args :[ id :number , bytes :Uint8Array < ArrayBuffer >]) :Promise < FileReply < number >>; 23export function op_net_writev ( args :[ id :number , buffers :Uint8Array < ArrayBuffer >[]]) :Promise < FileReply < number >>; 24export function op_net_shutdown ( id :number ) :Promise < FileReply < null >>; 25export function op_net_close ( id :number ) :FileReply < null >; 26export function op_net_datagram_listen ( address :NetUdpAddress & { __proto__ ?:null }) :FileReply < NetDatagram >; 27export function op_net_datagram_broadcast ( args :[ id :number , enabled :boolean ]) :FileReply < null >; 28export function op_net_datagram_receive ( 29args :[ id :number , count :number ], 30) :Promise < FileReply <[ Uint8Array < ArrayBuffer >, NetUdpAddress ]>>; 31export function op_net_datagram_send ( 32args :[ id :number , bytes :Uint8Array < ArrayBuffer >, target :NetUdpAddress ], 33) :Promise < FileReply < number >>; 34}