Skip to main content

decode_string_to

Function decode_string_to 

Source
pub fn decode_string_to<S: ProtoString>(
    buf: &mut impl Buf,
) -> Result<S, DecodeError>
Expand description

Decode a length-delimited string into a configurable ProtoString type by dispatching to ProtoString::decode_length_delimited.

The default hook hands a wire payload to from_wire, which decides validation and borrow-vs-own, so an inline-capable type avoids the transient String allocation that a From<String> path would force.

The declared length is checked only against the bytes left in buf. To decode a field of a message being merged, use decode_string_to_ctx, which also checks it against the end of that message.

§Errors