fn put<P: Into<PathBuf>>(&mut self, objects_dir: P) -> io::Result<()> {
        let objects_dir = objects_dir.into();

        // Accumulate the Object as a sequence of serialized byte slices.
        let mut sink = Accumulator {
            digester: sha1::Sha1::new(),
            encoder: zlib::Encoder::new(Vec::new())?
        };
        self.accumulate(&mut sink)?;

        // Calculate SHA1 checksum, prep directory and filepath.
        let digest = sink.digester.digest().to_string();
        let dir = &digest[0..2];
        let filename = &digest[2..];
        let fulldir = objects_dir.join(dir);
        let _ = fs::create_dir(&fulldir); // Catch error on file write.
        let fullpath = fulldir.join(filename);

        // Compress content using Zlib and write out.
        let encoded_data = sink.encoder.finish().into_result()?;
        fs::write(fullpath, encoded_data)?;
        Ok(())
    }
/// Put the Object into the content-addressable store.
Put the Object into the content-addressable store.
Put the Object into the content - addressable store .
fn put<P: Into<PathBuf>>(&mut self, objects_dir: P) -> io::Result<()> {
        let objects_dir = objects_dir.into();
        // Accumulate the Object as a sequence of serialized byte slices.
        let mut sink = Accumulator {
            digester: sha1::Sha1::new(),
            encoder: zlib::Encoder::new(Vec::new())?
        };
        self.accumulate(&mut sink)?;
        // Calculate SHA1 checksum, prep directory and filepath.
        let digest = sink.digester.digest().to_string();
        let dir = &digest[0..2];
        let filename = &digest[2..];
        let fulldir = objects_dir.join(dir);
        let _ = fs::create_dir(&fulldir); // Catch error on file write.
        let fullpath = fulldir.join(filename);
        // Compress content using Zlib and write out.
        let encoded_data = sink.encoder.finish().into_result()?;
        fs::write(fullpath, encoded_data)?;
        Ok(())
    }
fn put < P : Into < PathBuf > > ( & mut self , objects_dir : P ) -> io :: Result < ( ) > { let objects_dir = objects_dir . into ( ) ; // Accumulate the Object as a sequence of serialized byte slices. let mut sink = Accumulator { digester : sha1 :: Sha1 :: new ( ) , encoder : zlib :: Encoder :: new ( Vec :: new ( ) ) ? } ; self . accumulate ( & mut sink ) ? ; // Calculate SHA1 checksum, prep directory and filepath. let digest = sink . digester . digest ( ) . to_string ( ) ; let dir = & digest [ 0 .. 2 ] ; let filename = & digest [ 2 .. ] ; let fulldir = objects_dir . join ( dir ) ; let _ = fs :: create_dir ( & fulldir ) ; // Catch error on file write. let fullpath = fulldir . join ( filename ) ; // Compress content using Zlib and write out. let encoded_data = sink . encoder . finish ( ) . into_result ( ) ? ; fs :: write ( fullpath , encoded_data ) ? ; Ok ( ( ) ) }
Put the Object into the content-addressable store.
Put the Object into the content - addressable store .
&mut self
objects_dir
P
&mut self
objects_dir
P