:py:mod:`dissect.util.xmemoryview` ================================== .. py:module:: dissect.util.xmemoryview Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.util.xmemoryview.xmemoryview .. py:function:: xmemoryview(view: bytes, format: str) -> Union[memoryview, _xmemoryview] Cast a memoryview to the specified format, including endianness. The regular ``memoryview.cast()`` method only supports host endianness. While that should be fine 99% of the time (most of the world runs on little endian systems), we'd rather it be fine 100% of the time. This utility method ensures that by transparently converting between endianness if it doesn't match the host endianness. If the host endianness matches the requested endianness, this simply returns a regular ``memoryview.cast()``. See ``memoryview.cast()`` for more details on what that actually does. :param view: The bytes object or memoryview to cast. :param format: The format to cast to in ``struct`` format syntax. :raises ValueError: If the format is invalid. :raises TypeError: If the view is of an invalid type.