# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

import:
  - unfold_templates.yml

data.errorUnfolders:
  unfolderNoTarget: errNotInitialized
  unfolderErrUnknown: errUnsupported
  unfolderErrArrayStart: errExpectedArray
  unfolderErrObjectStart: errExpectedObject
  unfolderErrExpectKey: errExpectedObjectKey

main: |
  package gotype

  {{ range $name, $err := data.errorUnfolders }}
  type {{ $name }} struct {}
  {{ end }}

  {{ range $name, $err := data.errorUnfolders }}

  func (*{{ $name }}) OnNil(*unfoldCtx) error { return {{ $err }} }
  func (*{{ $name }}) OnBool(*unfoldCtx, bool) error { return {{ $err }} }
  func (*{{ $name }}) OnString(*unfoldCtx, string) error { return {{ $err }} }
  func (*{{ $name }}) OnStringRef(*unfoldCtx, []byte) error { return {{ $err }} }
  func (*{{ $name }}) OnInt8(*unfoldCtx, int8) error { return {{ $err }} }
  func (*{{ $name }}) OnInt16(*unfoldCtx, int16) error { return {{ $err }} }
  func (*{{ $name }}) OnInt32(*unfoldCtx, int32) error { return {{ $err }} }
  func (*{{ $name }}) OnInt64(*unfoldCtx, int64) error { return {{ $err }} }
  func (*{{ $name }}) OnInt(*unfoldCtx, int) error { return {{ $err }} }
  func (*{{ $name }}) OnByte(*unfoldCtx, byte) error { return {{ $err }} }
  func (*{{ $name }}) OnUint8(*unfoldCtx, uint8) error { return {{ $err }} }
  func (*{{ $name }}) OnUint16(*unfoldCtx, uint16) error { return {{ $err }} }
  func (*{{ $name }}) OnUint32(*unfoldCtx, uint32) error { return {{ $err }} }
  func (*{{ $name }}) OnUint64(*unfoldCtx, uint64) error { return {{ $err }} }
  func (*{{ $name }}) OnUint(*unfoldCtx, uint) error { return {{ $err }} }
  func (*{{ $name }}) OnFloat32(*unfoldCtx, float32) error { return {{ $err }} }
  func (*{{ $name }}) OnFloat64(*unfoldCtx, float64) error { return {{ $err }} }
  func (*{{ $name }}) OnArrayStart(*unfoldCtx, int, structform.BaseType) error { return {{ $err }} }
  func (*{{ $name }}) OnArrayFinished(*unfoldCtx) error { return {{ $err }} }
  func (*{{ $name }}) OnChildArrayDone(*unfoldCtx) error { return {{ $err }} }
  func (*{{ $name }}) OnObjectStart(*unfoldCtx, int, structform.BaseType) error { return {{ $err }} }
  func (*{{ $name }}) OnObjectFinished(*unfoldCtx) error { return {{ $err }} }
  func (*{{ $name }}) OnKey(*unfoldCtx, string) error { return {{ $err }} }
  func (*{{ $name }}) OnKeyRef(*unfoldCtx, []byte) error { return {{ $err }} }
  func (*{{ $name }}) OnChildObjectDone(*unfoldCtx) error { return {{ $err }} }

  {{ end }}
