Skip to main content

Module codec

Module codec 

Source
Expand description

Frames: a big-endian u32 length, then that many bytes of CBOR.

Enums§

CodecError

Constants§

MAX_FRAME
The largest frame a peer accepts. Requests and replies are metadata; a page of items is far smaller. The limit keeps a peer from making the other allocate without bound.
MAX_REPLY
RPC replies can span frames, but never exceed this aggregate budget.
MAX_REQUEST_TYPE
The most characters of a request’s type that request_type and rpc_request_type read: a client chooses it, up to a whole frame of it, and every type the protocol has is far shorter.

Functions§

decode
Decode one frame’s payload.
encode
Encode value as one frame’s payload.
encode_limited
Encode without allocating past limit, including for an oversized value.
encoded_len
How many bytes value encodes to, without keeping them: what a page’s budget is measured against.
read_frame
read_frame_bytes
Read one frame’s payload, refusing an oversized one before reading it.
read_frame_bytes_within
As read_frame_bytes, refusing a frame longer than max (at most MAX_FRAME) before anything is allocated for it.
read_frame_within
As read_frame, refusing a frame longer than max.
read_reply
read_reply_within
As read_reply, refusing a reply longer than max (at most MAX_REPLY) once its length is read, before any of it is held: what a request whose answer has a smaller bound of its own reads it with.
request_type
The type of a request payload, even one this build cannot decode, so the server can name it in crate::Error::Unsupported.
rpc_request_type
Extract a request tag from the mandatory RPC wrapper, including unknown tags.
write_frame
Write value as one frame. One over MAX_FRAME is refused before anything is written, so the writer can send something else instead.
write_reply
RPC reply: total encoded length, followed by length-prefixed chunks. The complete message is checked before any bytes are written.