Untitled

Pasted by zyp on Wed Apr 30 15:13:54 2025 UTC as Python
class Packet(data.StructLayout):
    def __init__(self, element_shape = 8, *, has_first = False, has_last = False):
        assert has_first or has_last
        layout = {'data': element_shape}
        if has_first:
            layout['first'] = 1
        if has_last:
            layout['last'] = 1
        super().__init__(layout)

        self.has_first = has_first
        self.has_last = has_last