Function base16::encode_config_buf
source ·
[−]pub fn encode_config_buf<T: ?Sized + AsRef<[u8]>>(
input: &T,
cfg: EncConfig,
dst: &mut String
) -> usizeExpand description
Encode input into the end of the provided buffer. Returns the number of
bytes that were written.
Only allocates when dst.size() + (input.len() * 2) >= dst.capacity().
Example
let messages = &["Taako, ", "Merle, ", "Magnus"];
let mut buffer = String::new();
for msg in messages {
let bytes_written = base16::encode_config_buf(msg.as_bytes(),
base16::EncodeUpper,
&mut buffer);
assert_eq!(bytes_written, msg.len() * 2);
}
assert_eq!(buffer, "5461616B6F2C204D65726C652C204D61676E7573");Availability
This function is only available when the alloc feature is enabled, as it
needs write to a String.
