pub fn read_content_from_buffer<T>(
        &self,
        reader: &mut std::io::BufReader<T>,
    ) -> Result<Vec<u8>, NeoXIndexError>
    where
        T: std::io::Read,
        T: std::io::Seek,
    {
        reader.seek(std::io::SeekFrom::Start(
            self.offset as u64 | (self.large_file_offset as u64) << 20,
        ))?;

        let mut buffer = vec![0; self.compressed_size as usize];
        trace!("Read NeoX source buffer");
        reader.read_exact(&mut buffer)?;

        trace!("Handle Encryption of type {:?}", self.encrypt_type);
        let unencrypted_buffer = match self.encrypt_type {
            NeoXIndex2EncryptType::None => buffer,
            NeoXIndex2EncryptType::RC4 => unimplemented!("RC4 is currently not supported"),
            NeoXIndex2EncryptType::Simple => {
                unimplemented!("Simple encrypt is currenlty not support")
            }
        };

        trace!("Handle Compression of type {:?}", self.compression_type);
        let uncompressed_buffer = match self.compression_type {
            NeoXIndex2CompressType::None => unencrypted_buffer,
            NeoXIndex2CompressType::LZ4 => {
                let mut decompressed = Vec::new();
                let len = compress::lz4::decode_block(&unencrypted_buffer, &mut decompressed);
                if len < 1 {
                    return Err(NeoXIndexError::DecompressFailedLZ4);
                }
                decompressed
            }
            NeoXIndex2CompressType::ZLib => {
                let mut decompressed = Vec::new();
                let res = compress::zlib::Decoder::new(std::io::Cursor::new(&unencrypted_buffer))
                    .read_to_end(&mut decompressed);
                if res.is_err() {
                    return Err(NeoXIndexError::DecompressFailedZLib);
                }
                decompressed
            }
        };

        Ok(uncompressed_buffer)
    }
// TODO(alexander): Try to merge this with t NeoXIndex1
Try to merge this with t NeoXIndex1
Try to merge this with t NeoXIndex1
pub fn read_content_from_buffer<T>(
        &self,
        reader: &mut std::io::BufReader<T>,
    ) -> Result<Vec<u8>, NeoXIndexError>
    where
        T: std::io::Read,
        T: std::io::Seek,
    {
        reader.seek(std::io::SeekFrom::Start(
            self.offset as u64 | (self.large_file_offset as u64) << 20,
        ))?;
        let mut buffer = vec![0; self.compressed_size as usize];
        trace!("Read NeoX source buffer");
        reader.read_exact(&mut buffer)?;
        trace!("Handle Encryption of type {:?}", self.encrypt_type);
        let unencrypted_buffer = match self.encrypt_type {
            NeoXIndex2EncryptType::None => buffer,
            NeoXIndex2EncryptType::RC4 => unimplemented!("RC4 is currently not supported"),
            NeoXIndex2EncryptType::Simple => {
                unimplemented!("Simple encrypt is currenlty not support")
            }
        };
        trace!("Handle Compression of type {:?}", self.compression_type);
        let uncompressed_buffer = match self.compression_type {
            NeoXIndex2CompressType::None => unencrypted_buffer,
            NeoXIndex2CompressType::LZ4 => {
                let mut decompressed = Vec::new();
                let len = compress::lz4::decode_block(&unencrypted_buffer, &mut decompressed);
                if len < 1 {
                    return Err(NeoXIndexError::DecompressFailedLZ4);
                }
                decompressed
            }
            NeoXIndex2CompressType::ZLib => {
                let mut decompressed = Vec::new();
                let res = compress::zlib::Decoder::new(std::io::Cursor::new(&unencrypted_buffer))
                    .read_to_end(&mut decompressed);
                if res.is_err() {
                    return Err(NeoXIndexError::DecompressFailedZLib);
                }
                decompressed
            }
        };
        Ok(uncompressed_buffer)
    }
pub fn read_content_from_buffer < T > ( & self , reader : & mut std :: io :: BufReader < T > , ) -> Result < Vec < u8 > , NeoXIndexError > where T : std :: io :: Read , T : std :: io :: Seek , { reader . seek ( std :: io :: SeekFrom :: Start ( self . offset as u64 | ( self . large_file_offset as u64 ) << 20 , ) ) ? ; let mut buffer = vec ! [ 0 self compressed_size as usize ] ; trace ! ( " " ) ; reader . read_exact ( & mut buffer ) ? ; trace ! ( " " self encrypt_type ) ; let unencrypted_buffer = match self . encrypt_type { NeoXIndex2EncryptType :: None => buffer , NeoXIndex2EncryptType :: RC4 => unimplemented ! ( " " ) , NeoXIndex2EncryptType :: Simple => { unimplemented ! ( " " ) } } ; trace ! ( " " self compression_type ) ; let uncompressed_buffer = match self . compression_type { NeoXIndex2CompressType :: None => unencrypted_buffer , NeoXIndex2CompressType :: LZ4 => { let mut decompressed = Vec :: new ( ) ; let len = compress :: lz4 :: decode_block ( & unencrypted_buffer , & mut decompressed ) ; if len < 1 { return Err ( NeoXIndexError :: DecompressFailedLZ4 ) ; } decompressed } NeoXIndex2CompressType :: ZLib => { let mut decompressed = Vec :: new ( ) ; let res = compress :: zlib :: Decoder :: new ( std :: io :: Cursor :: new ( & unencrypted_buffer ) ) . read_to_end ( & mut decompressed ) ; if res . is_err ( ) { return Err ( NeoXIndexError :: DecompressFailedZLib ) ; } decompressed } } ; Ok ( uncompressed_buffer ) }
TODO(alexander): Try to merge this with t NeoXIndex1
TODO ( alexander ) : Try to merge this with t NeoXIndex1
&self
reader
&mut std::io::BufReader<T>
&self
reader
&mut std::io::BufReader<T>