pub trait GenericRequest:
Encode
+ Decode
+ Send
+ Sync
+ 'static {
type Response: Encode + Decode + Send + Sync + 'static;
const PROTOCOL_NAME: &'static str;
const LOG_TARGET: &'static str;
// Provided methods
fn encode_response(response: &Self::Response) -> Option<ResponsePayload> { ... }
fn decode_response(
payload: SharedAlignedBuffer<Align1>,
) -> Result<Self::Response, Error> { ... }
}Expand description
Generic request with associated response
Required Associated Constants§
Sourceconst PROTOCOL_NAME: &'static str
const PROTOCOL_NAME: &'static str
Defines request-response protocol name.
Sourceconst LOG_TARGET: &'static str
const LOG_TARGET: &'static str
Specifies log-parameters for tracing.
Required Associated Types§
Provided Methods§
Sourcefn encode_response(response: &Self::Response) -> Option<ResponsePayload>
fn encode_response(response: &Self::Response) -> Option<ResponsePayload>
Encode a response into a payload, which must be decodable with Self::decode_response().
The default implementation encodes the response with SCALE codec, responses that contain large buffers can be encoded the same way without copying them into the payload instead.
Returns None if the response is too large.
Sourcefn decode_response(
payload: SharedAlignedBuffer<Align1>,
) -> Result<Self::Response, Error>
fn decode_response( payload: SharedAlignedBuffer<Align1>, ) -> Result<Self::Response, Error>
Decode a response received from a remote peer, the whole payload must be consumed.
The default implementation decodes the response with SCALE codec, responses that contain large buffers can reference them in the payload without copying them instead.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".