Add CompressedGitObject

As mentioned earlier, this struct is supposed to deal with compression/decompression.

src/git_object/compressed.rs
pub struct CompressedGitObject {
    pub compressed: Vec<u8>,
}

In the impl block we implement decompress function:

impl CompressedGitObject {
    pub fn decompress(buf_reader: impl BufRead) -> Result<SerializedGitObject, ObjectParseError> {
        let mut zlib = ZlibDecoder::new(buf_reader);
        let mut buffer = String::new();
        zlib.read_to_string(&mut buffer)?;
        Ok(SerializedGitObject::new(buffer))
    }
}

It decompresses all of the data in a buf_reader and returns a SerializedGitObject

Last updated