Skip to main content

peek_request_parameter

Function peek_request_parameter 

Source
pub fn peek_request_parameter(buf: &[u8]) -> Result<Option<&str>, DecodeError>
Expand description

Read CodeGeneratorRequest.parameter (field 2) straight off the wire, without decoding the request.

An option that governs how the request itself is decoded cannot be read from the decoded request. Scanning for the one field is what makes such options possible: it skips every other field rather than materialising it, so the cost is a wire walk, not a decode — microseconds against the tens of milliseconds a full decode of a large request takes.

Returns None when the request carries no parameter.

§Errors

Returns a DecodeError if the bytes are not well-formed protobuf, or if the parameter is not valid UTF-8.