| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Network.LibP2P.MultistreamSelect.Negotiation
Description
multistream-select protocol negotiation.
Implements Initiator and Responder roles for negotiating which protocol to use over a connection or stream.
Synopsis
- data NegotiationResult
- type ProtocolId = Text
- data StreamIO = StreamIO {
- streamWrite :: ByteString -> IO ()
- streamReadByte :: IO Word8
- streamClose :: IO ()
- negotiateInitiator :: StreamIO -> [ProtocolId] -> IO NegotiationResult
- negotiateResponder :: StreamIO -> [ProtocolId] -> IO NegotiationResult
- mkMemoryStreamPair :: IO (StreamIO, StreamIO)
Documentation
data NegotiationResult Source #
Result of a negotiation attempt.
Constructors
| Accepted !ProtocolId | |
| NoProtocol |
Instances
| Show NegotiationResult Source # | |
Defined in Network.LibP2P.MultistreamSelect.Negotiation Methods showsPrec :: Int -> NegotiationResult -> ShowS # show :: NegotiationResult -> String # showList :: [NegotiationResult] -> ShowS # | |
| Eq NegotiationResult Source # | |
Defined in Network.LibP2P.MultistreamSelect.Negotiation Methods (==) :: NegotiationResult -> NegotiationResult -> Bool # (/=) :: NegotiationResult -> NegotiationResult -> Bool # | |
type ProtocolId = Text Source #
A protocol identifier (e.g. "noise", "yamux/1.0.0").
Abstraction for stream I/O to enable testing with in-memory buffers.
Constructors
| StreamIO | |
Fields
| |
negotiateInitiator :: StreamIO -> [ProtocolId] -> IO NegotiationResult Source #
Negotiate as the Initiator. Sends header, then tries each protocol in order until one is accepted.
negotiateResponder :: StreamIO -> [ProtocolId] -> IO NegotiationResult Source #
Negotiate as the Responder. Receives header, then responds to the initiator's proposal.