o
     iL
                     @   s   d dl Z G dd deZdS )    Nc                   @   sF   e Zd ZdZdZdddZdd Zdd	 Zd
d Zdd Z	dd Z
dS )CommonChecksuma  Hashlib-alike helper for CRC32C operations.

    This class should not be used directly and requires an update implementation.

    Args:
        initial_value (Optional[bytes]): the initial chunk of data from
            which the CRC32C checksum is computed.  Defaults to b''.
         c                 C   s    d| _ |dkr| | d S d S )Nr   r   )_crcupdate)selfinitial_valuer   r   w/var/www/snowflake_co_dev_github/snow_flake_back_end_deploy/env/lib/python3.10/site-packages/google_crc32c/_checksum.py__init__   s   zCommonChecksum.__init__c                 C   s   t  )zUpdate the checksum with a new chunk of data.

        Args:
            chunk (Optional[bytes]): a chunk of data used to extend
                the CRC32C checksum.
        )NotImplemented)r   datar   r   r	   r   "   s   zCommonChecksum.updatec                 C   s   t d| jS )zBig-endian order, per RFC 4960.

        See: https://cloud.google.com/storage/docs/json_api/v1/objects#crc32c

        Returns:
            bytes: An eight-byte digest string.
        z>L)structpackr   r   r   r   r	   digest+   s   zCommonChecksum.digestc                 C   s   d | jdS )zLike :meth:`digest` except returns as a bytestring of double length.

        Returns
            bytes: A sixteen byte digest string, contaiing only hex digits.
        z{:08x}ascii)formatr   encoder   r   r   r	   	hexdigest5   s   zCommonChecksum.hexdigestc                 C   s   |   }| j|_|S )zvCreate another checksum with the same CRC32C value.

        Returns:
            Checksum: the new instance.
        )	__class__r   )r   cloner   r   r	   copy=   s   zCommonChecksum.copyc                 c   s(    	 | |}|sdS | | |V  q)a;  Consume chunks from a stream, extending our CRC32 checksum.

        Args:
            stream (BinaryIO): the stream to consume.
            chunksize (int): the size of the read to perform

        Returns:
            Generator[bytes, None, None]: Iterable of the chunks read from the
            stream.
        TN)readr   )r   stream	chunksizechunkr   r   r	   consumeG   s   

zCommonChecksum.consumeN)r   )__name__
__module____qualname____doc__	__slots__r
   r   r   r   r   r   r   r   r   r	   r      s    
	

r   )r   objectr   r   r   r   r	   <module>   s   