def _container_handler(ion_type, ctx):
    """Handler for the body of a container (or the top-level stream).

    Args:
        ion_type (Optional[IonType]): The type of the container or ``None`` for the top-level.
        ctx (_HandlerContext): The context for the container.
    """
    transition = None
    first = True
    at_top = ctx.depth == 0
    while True:
        data_event, self = (yield transition)
        if data_event is not None and data_event.type is ReadEventType.SKIP:
            yield ctx.read_data_transition(ctx.remaining, self, skip=True)

        if ctx.queue.position == ctx.limit:
            # We are at the end of the container.
            # Yield the close event and go to enclosing container.
            yield Transition(
                IonEvent(IonEventType.CONTAINER_END, ion_type, depth=ctx.depth-1),
                ctx.whence
            )

        if ion_type is IonType.STRUCT:
            # Read the field name.
            self_handler = _create_delegate_handler(self)
            (field_sid, _), _ = yield ctx.immediate_transition(
                _var_uint_field_handler(self_handler, ctx)
            )
            field_name = SymbolToken(None, field_sid)
        else:
            field_name = None

        expects_ivm = first and at_top
        transition = ctx.immediate_transition(
            _start_type_handler(field_name, self, ctx, expects_ivm, at_top=at_top)
        )
        first = False
def _container_handler ( ion_type , ctx ) : transition = None first = True at_top = ctx . depth == 0 while True : data_event , self = ( yield transition ) if data_event is not None and data_event . type is ReadEventType . SKIP : yield ctx . read_data_transition ( ctx . remaining , self , skip = True ) if ctx . queue . position == ctx . limit : yield Transition ( IonEvent ( IonEventType . CONTAINER_END , ion_type , depth = ctx . depth - 1 ) , ctx . whence ) if ion_type is IonType . STRUCT : self_handler = _create_delegate_handler ( self ) ( field_sid , _ ) , _ = yield ctx . immediate_transition ( _var_uint_field_handler ( self_handler , ctx ) ) field_name = SymbolToken ( None , field_sid ) else : field_name = None expects_ivm = first and at_top transition = ctx . immediate_transition ( _start_type_handler ( field_name , self , ctx , expects_ivm , at_top = at_top ) ) first = False
Handler for the body of a container (or the top-level stream).

    Args:
        ion_type (Optional[IonType]): The type of the container or ``None`` for the top-level.
        ctx (_HandlerContext): The context for the container.