network-mux
Safe HaskellNone
LanguageHaskell2010

Network.Mux.Codec

Synopsis

Documentation

encodeSDU :: SDU -> ByteString Source #

Encode a SDU as a ByteString.

Binary format used by 'encodeSDU' and 'decodeSDUHeader'
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        transmission time                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|d|    mini-protocol number     |             length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

All fields are in big endian byte order.

  • transmission time: time when the SDU was sent
  • d: mini-protocol direction (MiniProtocolDir):

    • 1 - initiator direction
    • 0 - responder direction
  • mini-protocol number (MiniProtocolNum)
  • length: length of the payload

decodeSDU :: ByteString -> Either Error SDU Source #

Decode a MuSDU header. A left inverse of encodeSDU.