/// Scans up-to `scan_len` bytes from the provided `BufStream` for a string that is terminated with
/// the appropriate null terminator for the given encoding as per the ID3v2 specification. A
/// copy-on-write reference to the string excluding the null terminator is returned or an error. If
/// the scanned string is valid UTF-8, or is equivalent to UTF-8, then no copies will occur. If a
/// null terminator is not found, and `scan_len` is reached, or the stream is exhausted, all the
/// scanned bytes up-to that point are interpreted as the string.
Scans up-to `scan_len` bytes from the provided `BufStream` for a string that is terminated with
the appropriate null terminator for the given encoding as per the ID3v2 specification. A
copy-on-write reference to the string excluding the null terminator is returned or an error. If
the scanned string is valid UTF-8, or is equivalent to UTF-8, then no copies will occur. If a
null terminator is not found, and `scan_len` is reached, or the stream is exhausted, all the
scanned bytes up-to that point are interpreted as the string.
Scans up - to ` scan_len ` bytes from the provided ` BufStream ` for a string that is terminated with the appropriate null terminator for the given encoding as per the ID3v2 specification . A copy - on - write reference to the string excluding the null terminator is returned or an error . If the scanned string is valid UTF - 8 or is equivalent to UTF - 8 then no copies will occur . If a null terminator is not found and ` scan_len ` is reached or the stream is exhausted all the scanned bytes up - to that point are interpreted as the string .
fn scan_text<'a>(
    reader: &'a mut BufStream<'_>,
    encoding: Encoding,
    scan_len: usize,
) -> io::Result<Cow<'a, str>> {
    let buf = match encoding {
        Encoding::Iso8859_1 | Encoding::Utf8 => {
            reader.scan_bytes_aligned_ref(&[0x00], 1, scan_len)
        },
        Encoding::Utf16Bom  | Encoding::Utf16Be => {
            reader.scan_bytes_aligned_ref(&[0x00, 0x00], 2, scan_len)
        }
    }?;
    Ok(decode_text(encoding, buf))
}
fn scan_text < ' a > ( reader : & ' a mut BufStream < ' _ > , encoding : Encoding , scan_len : usize , ) -> io :: Result < Cow < ' a , str > > { let buf = match encoding { Encoding :: Iso8859_1 | Encoding :: Utf8 => { reader . scan_bytes_aligned_ref ( & [ 0x00 ] , 1 , scan_len ) } , Encoding :: Utf16Bom | Encoding :: Utf16Be => { reader . scan_bytes_aligned_ref ( & [ 0x00 , 0x00 ] , 2 , scan_len ) } } ? ; Ok ( decode_text ( encoding , buf ) ) }
Scans up-to `scan_len` bytes from the provided `BufStream` for a string that is terminated with
the appropriate null terminator for the given encoding as per the ID3v2 specification.
Scans up - to ` scan_len ` bytes from the provided ` BufStream ` for a string that is terminated with the appropriate null terminator for the given encoding as per the ID3v2 specification .
reader
&'a mut BufStream<'_>
encoding
Encoding
scan_len
usize