Skip to content

Fileable and BinaryFile superclass #4

@logicplace

Description

@logicplace

Depends on: #1

Superclass for fileable structs. These are structs which represent what one could think of as a standard file format, like PNG (vs graphic, which does not), XML, etc.

Fileable subclasses must implement the methods:

  • to_file(self, data: BytesBuffer)
  • from_file(self, data: BytesBuffer)

Any keyword-only arguments defined in these are keys to pull, like in calculations.

BinaryFIle essentially just sets to_file = serialize etc

These are decorated methods, so that the interfaces when calling them are like this (the returning None is only for explicitness):

def to_file(self, data: BytesBuffer) -> None: ...
def to_file(self) -> bytes: ...
def from_file(self, data: BytesBuffer) -> None: ...
def from_file(self, data: bytes) -> None: ...

# TextFile, when implemented, should also accept:
def from_file(self, data: str) -> None: ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions