Docs.rs
  • libp2p-request-response-0.17.0
    • libp2p-request-response 0.17.0
    • Docs.rs crate page
    • MIT
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • jxs
    • mxinden
    • github:paritytech:libp2p-devs
    • romanb
    • github:libp2p:repos-rust
    • github:libp2p:rust-libp2p-maintainers
    • Dependencies
      • async-trait ^0.1 normal
      • bytes ^1 normal
      • futures ^0.3.1 normal
      • instant ^0.1.11 normal
      • libp2p-core ^0.32.0 normal
      • libp2p-swarm ^0.35.0 normal
      • log ^0.4.11 normal
      • rand ^0.7 normal
      • smallvec ^1.6.1 normal
      • unsigned-varint ^0.7 normal
      • async-std ^1.6.2 dev
      • env_logger ^0.9.0 dev
      • rand ^0.7 dev
    • Versions
    • 97.1% of the crate is documented
  • Go to latest version
  • Platform
    • i686-unknown-linux-gnu
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation
logo

Crate libp2p_request_response

logo

Crate libp2p_request_response

  • Version 0.17.0
  • All Items
  • Modules
  • Structs
  • Enums
  • Traits

Modules

  • codec
  • handler

Structs

  • RequestId
  • RequestResponse
  • RequestResponseConfig
  • ResponseChannel

Enums

  • InboundFailure
  • OutboundFailure
  • ProtocolSupport
  • RequestResponseEvent
  • RequestResponseMessage

Traits

  • ProtocolName
logo
Change settings

Crate libp2p_request_response

source · [−]
Expand description

Generic request/response protocols.

General Usage

RequestResponse is a NetworkBehaviour that implements a generic request/response protocol or protocol family, whereby each request is sent over a new substream on a connection. RequestResponse is generic over the actual messages being sent, which are defined in terms of a RequestResponseCodec. Creating a request/response protocol thus amounts to providing an implementation of this trait which can then be given to RequestResponse::new. Further configuration options are available via the RequestResponseConfig.

Requests are sent using RequestResponse::send_request and the responses received as RequestResponseMessage::Response via RequestResponseEvent::Message.

Responses are sent using RequestResponse::send_response upon receiving a RequestResponseMessage::Request via RequestResponseEvent::Message.

Protocol Families

A single RequestResponse instance can be used with an entire protocol family that share the same request and response types. For that purpose, RequestResponseCodec::Protocol is typically instantiated with a sum type.

Limited Protocol Support

It is possible to only support inbound or outbound requests for a particular protocol. This is achieved by instantiating RequestResponse with protocols using ProtocolSupport::Inbound or ProtocolSupport::Outbound. Any subset of protocols of a protocol family can be configured in this way. Such protocols will not be advertised during inbound respectively outbound protocol negotiation on the substreams.

Re-exports

pub use codec::RequestResponseCodec;

Modules

codec
handler

Structs

RequestId

The ID of an inbound or outbound request.

RequestResponse

A request/response protocol for some message codec.

RequestResponseConfig

The configuration for a RequestResponse protocol.

ResponseChannel

A channel for sending a response to an inbound request.

Enums

InboundFailure

Possible failures occurring in the context of receiving an inbound request and sending a response.

OutboundFailure

Possible failures occurring in the context of sending an outbound request and receiving the response.

ProtocolSupport

The level of support for a particular protocol.

RequestResponseEvent

The events emitted by a RequestResponse protocol.

RequestResponseMessage

An inbound request or response.

Traits

ProtocolName

Types serving as protocol names.

Loading search results...