fn collect_data(&self) -> Result<Vec<u8>, CollectDataError> {
        let mut outp = Vec::new();
        let mut keys = Vec::new();
        for key in self.chunks.keys() {
            keys.push(key);
        }
        keys.sort();
        let mut last_key = 0;
        for key in keys.iter() {
            if *key - last_key > 1 { return Err(CollectDataError::DiscontinuousContentIDs); }
            outp.extend(self.chunks.get(key).unwrap());
        }
        let mut hasher = Sha3_256::new();
        hasher.update(&outp);
        let hash = hasher.finalize();
        if hash.as_slice() != self.target_hash { return Err(CollectDataError::HashMismatch); }
        Ok(outp)
    }
/// Try to assemble a complete file out of the chunks loaded in.
Try to assemble a complete file out of the chunks loaded in.
Try to assemble a complete file out of the chunks loaded in .
fn collect_data(&self) -> Result<Vec<u8>, CollectDataError> {
        let mut outp = Vec::new();
        let mut keys = Vec::new();
        for key in self.chunks.keys() {
            keys.push(key);
        }
        keys.sort();
        let mut last_key = 0;
        for key in keys.iter() {
            if *key - last_key > 1 { return Err(CollectDataError::DiscontinuousContentIDs); }
            outp.extend(self.chunks.get(key).unwrap());
        }
        let mut hasher = Sha3_256::new();
        hasher.update(&outp);
        let hash = hasher.finalize();
        if hash.as_slice() != self.target_hash { return Err(CollectDataError::HashMismatch); }
        Ok(outp)
    }
fn collect_data ( & self ) -> Result < Vec < u8 > , CollectDataError > { let mut outp = Vec :: new ( ) ; let mut keys = Vec :: new ( ) ; for key in self . chunks . keys ( ) { keys . push ( key ) ; } keys . sort ( ) ; let mut last_key = 0 ; for key in keys . iter ( ) { if * key - last_key > 1 { return Err ( CollectDataError :: DiscontinuousContentIDs ) ; } outp . extend ( self . chunks . get ( key ) . unwrap ( ) ) ; } let mut hasher = Sha3_256 :: new ( ) ; hasher . update ( & outp ) ; let hash = hasher . finalize ( ) ; if hash . as_slice ( ) != self . target_hash { return Err ( CollectDataError :: HashMismatch ) ; } Ok ( outp ) }
Try to assemble a complete file out of the chunks loaded in.
Try to assemble a complete file out of the chunks loaded in .
&self
&self