quic-simple-0.1.1.0: Quick-start wrappers for QUIC
Safe HaskellNone
LanguageGHC2021

Network.QUIC.Simple.Stream

Synopsis

Documentation

type MessageQueues sendMsg recvMsg = (TBQueue sendMsg, TBQueue recvMsg) Source #

A pair of bounded queues wrapping a stream.

streamSerialise :: (Serialise sendMsg, Serialise recvMsg) => Stream -> IO (Async (), MessageQueues sendMsg recvMsg) Source #

Wrap the stream with the CBOR codec for both incoming and outgoing messages.

The decoder will perform incremental parsing and emit complete messages.

No extra framing is required since CBOR is self-delimiting.

streamCodec Source #

Arguments

:: (sendMsg -> ByteString)

Encoder for outgoing messages

-> (ByteString -> IO (ByteString, Maybe recvMsg))

Decoder for incomming chunks

-> Stream 
-> IO (Async (), MessageQueues sendMsg recvMsg) 

Wrap the stream with a codec to provide a TBQueue interface to it.

The decoder loop is stateless. But it runs in IO so you can use external state and terminate the stream by erroring out.