pub fn read_string<R: ::std::io::Read>(reader: &mut R) -> Result<String, DecodeError> {
    let len: BigSize = Readable::read(reader)?;

    if len.0 > MAX_VEC_SIZE {
        return Err(DecodeError::InvalidValue);
    }

    let mut buf = Vec::with_capacity(len.0 as usize);

    for _ in 0..len.0 {
        let b: u8 = Readable::read(reader)?;
        buf.push(b);
    }

    let res = match String::from_utf8(buf) {
        Ok(s) => s,
        Err(_) => return Err(DecodeError::InvalidValue),
    };

    Ok(res)
}
/// Reads a string from the given reader.
Reads a string from the given reader.
Reads a string from the given reader .
pub fn read_string<R: ::std::io::Read>(reader: &mut R) -> Result<String, DecodeError> {
    let len: BigSize = Readable::read(reader)?;
    if len.0 > MAX_VEC_SIZE {
        return Err(DecodeError::InvalidValue);
    }
    let mut buf = Vec::with_capacity(len.0 as usize);
    for _ in 0..len.0 {
        let b: u8 = Readable::read(reader)?;
        buf.push(b);
    }
    let res = match String::from_utf8(buf) {
        Ok(s) => s,
        Err(_) => return Err(DecodeError::InvalidValue),
    };
    Ok(res)
}
pub fn read_string < R : :: std :: io :: Read > ( reader : & mut R ) -> Result < String , DecodeError > { let len : BigSize = Readable :: read ( reader ) ? ; if len . 0 > MAX_VEC_SIZE { return Err ( DecodeError :: InvalidValue ) ; } let mut buf = Vec :: with_capacity ( len . 0 as usize ) ; for _ in 0 .. len . 0 { let b : u8 = Readable :: read ( reader ) ? ; buf . push ( b ) ; } let res = match String :: from_utf8 ( buf ) { Ok ( s ) => s , Err ( _ ) => return Err ( DecodeError :: InvalidValue ) , } ; Ok ( res ) }
Reads a string from the given reader.
Reads a string from the given reader .
reader
&mut R