import struct


def binary_format(encoding_size):
    """
    Return a Struct instance with the binary format of the encodings.

    The binary format string can be understood as:
    - "!" Use network byte order (big-endian).
    - "I" store the entity ID as an unsigned int
    - "<encoding size>s" Store the n (e.g. 128) raw bytes of the bitarray

    https://docs.python.org/3/library/struct.html

    :param encoding_size: the encoding size of one filter in number of bytes, excluding the entity ID info
    :return:
        A Struct object which can read and write the binary format.
    """
    bit_packing_fmt = f"!I{encoding_size}s"
    bit_packing_struct = struct.Struct(bit_packing_fmt)
    return bit_packing_struct