import ctypes


def struct_unpack(structure, raw_data):
	"""
	Convert *raw_data* to an instance of *structure*.

	:param structure: The structure that describes *raw_data*.
	:type structure: :py:class:`ctypes.Structure`
	:param bytes raw_data: The binary string which contains the structures data.
	:return: A new instance of *structure*.
	:rtype: :py:class:`ctypes.Structure`
	"""
	if not isinstance(structure, ctypes.Structure):
		structure = structure()
	ctypes.memmove(ctypes.byref(structure), raw_data, ctypes.sizeof(structure))
	return structure