docs: def _lob_end_handler_factory(ion_type, action, validate=lambda c, ctx, action_res: None):
      """Generates handlers for the end of blob or clob values.
  
      Args:
          ion_type (IonType): The type of this lob (either blob or clob).
          action (callable): Called for each non-whitespace, non-closing brace character encountered before the end of
              the lob. Accepts the current character's ordinal, the current context, the previous character's ordinal,
              the result of the previous call to ``action`` (if any), and True if this is the first call to ``action``.
              Returns any state that will be needed by subsequent calls to ``action``. For blobs, this should validate
              the character is valid base64; for clobs, this should ensure there are no illegal characters (e.g. comments)
              between the end of the data and the end of the clob.
          validate (Optional[callable]): Called once the second closing brace has been found. Accepts the current
              character's ordinal, the current context, and the result of the last call to ``action``; raises an error
              if this is not a valid lob value.
      """
      assert ion_type is IonType.BLOB or ion_type is IonType.CLOB
  
      @coroutine
      def lob_end_handler(c, ctx):
          val = ctx.value
          prev = c
          action_res = None
          if c != _CLOSE_BRACE and c not in _WHITESPACE:
              action_res = action(c, ctx, prev, action_res, True)
          c, self = yield
          trans = ctx.immediate_transition(self)
          while True:
              if c in _WHITESPACE:
                  if prev == _CLOSE_BRACE:
                      _illegal_character(c, ctx.set_ion_type(ion_type), 'Expected }.')
              elif c == _CLOSE_BRACE:
                  if prev == _CLOSE_BRACE:
                      validate(c, ctx, action_res)
                      break
              else:
                  action_res = action(c, ctx, prev, action_res, False)
              prev = c
              c, _ = yield trans
          ctx.set_self_delimiting(True)  # Lob values are self-delimiting (they are terminated by '}}').
          yield ctx.event_transition(IonThunkEvent, IonEventType.SCALAR, ion_type, _parse_lob(ion_type, val))
      return lob_end_handler