pub struct CallBuf { /* private fields */ }Expand description
Payload of an outgoing RPC call, with room reserved ahead of it for the record mark and call header the driver writes when it sends the call.
Encoding arguments straight into a CallBuf lets the driver frame the
call in place: it fills the reserved prefix and hands the buffer to the
socket without copying or shifting the payload. Callers read only the
payload; append_with hands a serializer the
record buffer to extend in place, with the prefix kept reserved.
Implementations§
Source§impl CallBuf
impl CallBuf
Sourcepub const PREFIX_LEN: usize
pub const PREFIX_LEN: usize
Bytes reserved ahead of the payload: a 4-byte record mark and the
40-byte RFC 5531 CALL header with AUTH_NONE credentials and
verifier. The driver only ever sends that header, so this is a
constant of the wire format.
Sourcepub fn new() -> Self
pub fn new() -> Self
Buffer with an empty payload.
Prefer RpcSender::call_buf, which recycles a spent buffer instead
of allocating. There is deliberately no Default: a buffer should
come from a sender unless there is none.
Sourcepub fn append_with<R>(&mut self, f: impl FnOnce(&mut Vec<u8>) -> R) -> R
pub fn append_with<R>(&mut self, f: impl FnOnce(&mut Vec<u8>) -> R) -> R
Append to the payload through the record buffer itself.
f receives the whole record Vec<u8>, the reserved prefix followed
by the payload so far, appends to it, and its return value is passed
back. Generated protocol clients serialize their argument tuple this
way, straight into the buffer with the XDR serializer they were
generated against, so the driver sends the record without copying it
and this crate carries no serializer dependency of its own.
f must only append. The buffer is kept at least
PREFIX_LEN long afterwards, so an f that
shortens it cannot unreserve the prefix; the driver overwrites the
prefix bytes when it frames the call, so their contents never matter.
Sourcepub fn extend_from_slice(&mut self, bytes: &[u8])
pub fn extend_from_slice(&mut self, bytes: &[u8])
Append bytes to the payload.