[−][src]Function base65536::decode_slice
pub fn decode_slice<T: ?Sized>(
input: &T,
buf: &mut [u8],
ignore_garbage: bool
) -> DecodeResult<usize> where
T: AsRef<str>,
Decode from a reference to a base65536-encoded string as octets. Writes into the supplied slice, returning how many bytes were written.
Panics
Panics if the slice is not long enough.
Errors
If the input string contains a character not inside of a base65536 block,
Error::InvalidCodePoint will be retuned, along with the bad character,
and it's position in the input.
Note that decode, decode_buf, and decode_slice are very
strict by default, even failing on line breaks (such as those generated by
encode and encode_buf when wrapping is enabled),
as to match behaviour with the original implementation. To prevent this,
use with the ignore_garbage option.
If the base65536 stream continues after a terminating padding character,
Error::InvalidLength is returned.
Examples
use base65536::decode_slice; let mut buf = [0; 3]; decode_slice("㘁ᔃ", &mut buf, false)?; assert_eq!([1, 2, 3], buf); let mut buf = [0; 11]; decode_slice("驨ꍬ啯𒁷ꍲᕤ", &mut buf, false)?; assert_eq!(b"hello world", &buf);