Type Alias Behaviour
pub type Behaviour<Req, Resp> = Behaviour<Codec<Req, Resp>>;
Available on crate feature
request-response
only.Expand description
A request-response behaviour using [cbor4ii::serde
] for serializing and
deserializing the messages.
§Default Size Limits
The codec uses the following default size limits:
- Maximum request size: 1,048,576 bytes (1 MiB)
- Maximum response size: 10,485,760 bytes (10 MiB)
These limits can be customized with codec::Codec::set_request_size_maximum
and codec::Codec::set_response_size_maximum
.
§Example
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct GreetRequest {
name: String,
}
#[derive(Debug, serde::Serialize, serde::Deserialize)]
struct GreetResponse {
message: String,
}
let behaviour = cbor::Behaviour::<GreetRequest, GreetResponse>::new(
[(
StreamProtocol::new("/my-cbor-protocol"),
ProtocolSupport::Full,
)],
request_response::Config::default(),
);
Aliased Type§
struct Behaviour<Req, Resp> { /* private fields */ }