pub fn decode_string(buf: &mut impl Buf) -> Result<String, DecodeError>Expand description
Decode a string value: read a varint length prefix, then that many bytes,
and validate that the bytes are valid UTF-8.
§Errors
DecodeError::UnexpectedEofif the buffer has fewer bytes than the declared length.DecodeError::MessageTooLargeif the declared length overflowsusize.DecodeError::InvalidUtf8if the bytes are not valid UTF-8.
§Panics
If buf.chunk() returns an empty slice before buf.remaining() bytes have
been read — a Buf that violates its own contract.