| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
LibP2P.Yamux.Frame
Description
Yamux frame header encoding/decoding.
Every Yamux frame has a fixed 12-byte header: Version (1) | Type (1) | Flags (2 BE) | StreamID (4 BE) | Length (4 BE)
Synopsis
- data FrameType
- data Flags = Flags {}
- data YamuxHeader = YamuxHeader {}
- data GoAwayCode
- goAwayCodeToWord32 :: GoAwayCode -> Word32
- word32ToGoAwayCode :: Word32 -> Maybe GoAwayCode
- encodeHeader :: YamuxHeader -> ByteString
- decodeHeader :: ByteString -> Either String YamuxHeader
- defaultFlags :: Flags
- headerSize :: Int
- initialWindowSize :: Word32
- maxStreamWindowSize :: Word32
Documentation
Yamux frame types.
Constructors
| FrameData | 0x00: Data frame with payload |
| FrameWindowUpdate | 0x01: Window size increment |
| FramePing | 0x02: Keepalive/latency measurement |
| FrameGoAway | 0x03: Session termination |
Frame flags (bitmask).
Constructors
| Flags | |
data YamuxHeader Source #
Complete Yamux frame header (12 bytes).
Constructors
| YamuxHeader | |
Instances
| Show YamuxHeader Source # | |
Defined in LibP2P.Yamux.Frame Methods showsPrec :: Int -> YamuxHeader -> ShowS # show :: YamuxHeader -> String # showList :: [YamuxHeader] -> ShowS # | |
| Eq YamuxHeader Source # | |
Defined in LibP2P.Yamux.Frame | |
data GoAwayCode Source #
Go Away error codes.
Constructors
| GoAwayNormal | 0x00: Normal termination |
| GoAwayProtocol | 0x01: Protocol error |
| GoAwayInternal | 0x02: Internal error |
Instances
| Show GoAwayCode Source # | |
Defined in LibP2P.Yamux.Frame Methods showsPrec :: Int -> GoAwayCode -> ShowS # show :: GoAwayCode -> String # showList :: [GoAwayCode] -> ShowS # | |
| Eq GoAwayCode Source # | |
Defined in LibP2P.Yamux.Frame | |
goAwayCodeToWord32 :: GoAwayCode -> Word32 Source #
Wire encoding of a GoAway code (carried in the Length field).
word32ToGoAwayCode :: Word32 -> Maybe GoAwayCode Source #
Decode a received GoAway code. The spec defines only 0x00-0x02; anything else is Nothing and the receiver decides how to treat it.
encodeHeader :: YamuxHeader -> ByteString Source #
Encode a Yamux header to 12 bytes.
decodeHeader :: ByteString -> Either String YamuxHeader Source #
Decode a Yamux header from 12 bytes.
defaultFlags :: Flags Source #
No flags set.
headerSize :: Int Source #
Yamux header size is always 12 bytes.
initialWindowSize :: Word32 Source #
Default initial window size: 256 KiB (262144 bytes).
maxStreamWindowSize :: Word32 Source #
Absolute upper bound for any receive window (16 MiB), matching go-yamux's MaxStreamWindowSize. No conforming peer may declare a data frame length beyond this, whatever the per-stream window is.