fn read(&mut self, bytes: i64) -> Option<Vec<u8>> {
        let mut buffer = Vec::new();

        //for a defined number of bytes, i.e. bytes != -1
        if bytes > 0 {
            let mut handle = self.cursor.clone().take(bytes as u64);
            //read handle into buffer

            if handle.read_to_end(&mut buffer).is_err() {
                return None;
            }
            //the take above consumes the struct value
            //we add this back in with the takes into_inner method
            self.cursor = handle.into_inner();
        } else {
            //read handle into buffer
            if self.cursor.read_to_end(&mut buffer).is_err() {
                return None;
            }
        };

        Some(buffer)
    }
//Read k bytes from the object and return.
Read k bytes from the object and return.
Read k bytes from the object and return .
fn read(&mut self, bytes: i64) -> Option<Vec<u8>> {
        let mut buffer = Vec::new();
        //for a defined number of bytes, i.e. bytes != -1
        if bytes > 0 {
            let mut handle = self.cursor.clone().take(bytes as u64);
            //read handle into buffer
            if handle.read_to_end(&mut buffer).is_err() {
                return None;
            }
            //the take above consumes the struct value
            //we add this back in with the takes into_inner method
            self.cursor = handle.into_inner();
        } else {
            //read handle into buffer
            if self.cursor.read_to_end(&mut buffer).is_err() {
                return None;
            }
        };
        Some(buffer)
    }
fn read ( & mut self , bytes : i64 ) -> Option < Vec < u8 > > { let mut buffer = Vec :: new ( ) ; //for a defined number of bytes, i.e. bytes != -1 if bytes > 0 { let mut handle = self . cursor . clone ( ) . take ( bytes as u64 ) ; //read handle into buffer if handle . read_to_end ( & mut buffer ) . is_err ( ) { return None ; } //the take above consumes the struct value //we add this back in with the takes into_inner method self . cursor = handle . into_inner ( ) ; } else { //read handle into buffer if self . cursor . read_to_end ( & mut buffer ) . is_err ( ) { return None ; } } ; Some ( buffer ) }
Read k bytes from the object and return.
Read k bytes from the object and return .
&mut self
bytes
i64