import struct


def vox_chunk( id: bytes, content: bytes, children: bytes ) -> bytes:
  """Produces the chunk structure. Every chunk has a 4-byte long identifier
  (e.g. 'SIZE'), optional content, and optional child chunks. The payload
  and child chunks should by constructed by external functions, this function
  packs them together.

  Example
  -------
  >>> vox_chunk( 'SIZE', vox_size_content(10,10,10), b'' )
  
  While 'vox_size_content(..)' produces the content for the chunk, the full
  chunk (without child chunks) composed by this function.
  """
  assert( len( id ) == 4 )
  w = bytearray( )
  w.extend( id )
  w.extend( struct.pack( '<II', len( content ), len( children ) ) )
  w.extend( content )
  w.extend( children )
  return bytes( w )