# quic-simple
A set of wrappers for getting started with QUIC easier.
- `QUIC.runServer [("127.0.0.1", 14443)] \conn stream ->` -- start a generic server with random TLS credentials and auto-accept the first stream.
- `QUIC.runClient "127.0.0.1" "14443" \conn stream ->` -- start a generic client and request an initial stream.
- `(writeQ, readQ) <- Stream.codec encode decodeIncremental stream` -- convert a stream to a pair of queues.
- `(writeQ, readQ) <- Stream.serialise stream` -- run a CBOR codec over a stream.
Handshakes and multiple streams per connection, with `import Network.QUIC.Simple.Stream qualified as Stream`:
- `Stream.sendMessage stream hello` / `(reply, leftovers) <- Stream.recvMessage stream` -- exchange one-shot CBOR messages on a bare stream.
- `stream <- Stream.open conn header` -- request a stream and announce its protocol with a header message.
- `Stream.acceptLoop conn \header leftovers stream ->` -- accept the peer's streams and dispatch them by header, each in its own thread.
- `Stream.serialiseFrom leftovers stream` / `Stream.consume leftovers stream sink` -- continue a stream after its header with CBOR messages or raw bytes.
An extra-simple pair of wrappers for QUIC and dirty RPC:
- `QUIC.runServerSimple "127.0.0.1" 14443 handleCall` -- start a CBOR server running `streamSerialise`.
- `(stop, call) <- QUIC.startClientSimple "127.0.0.1" "14443"` -- spawn a CBOR client running `streamSerialise`.
See [tests](./test/Spec.hs) for copypastable examples of different wrapping levels.