pub fn commit(mut self) -> Result<Integrity, Error> {
        let writer_sri = self.writer.close()?;
        if let Some(sri) = &self.opts.sri {
            // TODO - ssri should have a .matches method
            let algo = sri.pick_algorithm();
            let matched = sri
                .hashes
                .iter()
                .take_while(|h| h.algorithm == algo)
                .find(|&h| *h == writer_sri.hashes[0]);
            if matched.is_none() {
                return Err(Error::IntegrityError);
            }
        } else {
            self.opts.sri = Some(writer_sri);
        }
        if let Some(size) = self.opts.size {
            if size != self.written {
                return Err(Error::SizeError);
            }
        }
        index::insert(&self.cache, &self.key, self.opts)
    }
/// Closes the Put handle and writes content and index entries. Also
/// verifies data against `size` and `integrity` options, if provided.
/// Must be called manually in order to complete the writing process,
/// otherwise everything will be thrown out.
Closes the Put handle and writes content and index entries. Also
verifies data against `size` and `integrity` options, if provided.
Must be called manually in order to complete the writing process,
otherwise everything will be thrown out.
Closes the Put handle and writes content and index entries . Also verifies data against ` size ` and ` integrity ` options if provided . Must be called manually in order to complete the writing process otherwise everything will be thrown out .
pub fn commit(mut self) -> Result<Integrity, Error> {
        let writer_sri = self.writer.close()?;
        if let Some(sri) = &self.opts.sri {
            // TODO - ssri should have a .matches method
            let algo = sri.pick_algorithm();
            let matched = sri
                .hashes
                .iter()
                .take_while(|h| h.algorithm == algo)
                .find(|&h| *h == writer_sri.hashes[0]);
            if matched.is_none() {
                return Err(Error::IntegrityError);
            }
        } else {
            self.opts.sri = Some(writer_sri);
        }
        if let Some(size) = self.opts.size {
            if size != self.written {
                return Err(Error::SizeError);
            }
        }
        index::insert(&self.cache, &self.key, self.opts)
    }
pub fn commit ( mut self ) -> Result < Integrity , Error > { let writer_sri = self . writer . close ( ) ? ; if let Some ( sri ) = & self . opts . sri { // TODO - ssri should have a .matches method let algo = sri . pick_algorithm ( ) ; let matched = sri . hashes . iter ( ) . take_while ( | h | h . algorithm == algo ) . find ( | & h | * h == writer_sri . hashes [ 0 ] ) ; if matched . is_none ( ) { return Err ( Error :: IntegrityError ) ; } } else { self . opts . sri = Some ( writer_sri ) ; } if let Some ( size ) = self . opts . size { if size != self . written { return Err ( Error :: SizeError ) ; } } index :: insert ( & self . cache , & self . key , self . opts ) }
Closes the Put handle and writes content and index entries.
Closes the Put handle and writes content and index entries .
mut self
mut self