:py:mod:`dissect.evidence.asdf.streams` ======================================= .. py:module:: dissect.evidence.asdf.streams Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.evidence.asdf.streams.SubStreamBase dissect.evidence.asdf.streams.Crc32Stream dissect.evidence.asdf.streams.HashedStream dissect.evidence.asdf.streams.CompressedStream .. py:class:: SubStreamBase(fh: BinaryIO) Bases: :py:obj:`io.RawIOBase` Convenience class for easy sub stream subclassing. Additionally adds the `finalize` method. :param fh: The file-like object to wrap. .. py:method:: write(b: bytes) -> int .. py:method:: tell() -> int Return current stream position. .. py:method:: seek(pos: int, whence: int = io.SEEK_CUR) -> int Change stream position. Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are: * 0 -- start of stream (the default); offset should be zero or positive * 1 -- current stream position; offset may be negative * 2 -- end of stream; offset is usually negative Return the new absolute position. .. py:method:: close() -> None Flush and close the IO object. This method has no effect if the file is already closed. .. py:method:: finalize() -> None .. py:class:: Crc32Stream(fh: BinaryIO) Bases: :py:obj:`SubStreamBase` Compute a CRC32 over all written data. This assumes that all data is written as a continuous stream. :param fh: The file-like object to wrap. .. py:method:: write(b: bytes) -> int .. py:method:: digest() -> bytes .. py:method:: finalize() -> None .. py:class:: HashedStream(fh: BinaryIO, alg: str = 'sha256') Bases: :py:obj:`SubStreamBase` Compute a hash over all written data. This assumes that all data is written as a continuous stream. :param fh: The file-like object to wrap. :param alg: The hashing algorithm to use. Must be supported by hashlib. .. py:method:: write(b: bytes) -> int .. py:method:: digest() -> bytes .. py:method:: hexdigest() -> str .. py:method:: close() -> None Flush and close the IO object. This method has no effect if the file is already closed. .. py:class:: CompressedStream(fh: BinaryIO) Bases: :py:obj:`SubStreamBase` Compress data as it's being written. This assumes that all data is written as a continuous stream. :param fh: The file-like object to wrap. .. py:method:: write(b: bytes) -> int .. py:method:: finalize() -> None