go.uber.org/yarpc@v1.72.1/encoding/thrift/internal/observabilitytest/test/test.go (about)

     1  // Code generated by thriftrw v1.29.2. DO NOT EDIT.
     2  // @generated
     3  
     4  // Copyright (c) 2022 Uber Technologies, Inc.
     5  //
     6  // Permission is hereby granted, free of charge, to any person obtaining a copy
     7  // of this software and associated documentation files (the "Software"), to deal
     8  // in the Software without restriction, including without limitation the rights
     9  // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    10  // copies of the Software, and to permit persons to whom the Software is
    11  // furnished to do so, subject to the following conditions:
    12  //
    13  // The above copyright notice and this permission notice shall be included in
    14  // all copies or substantial portions of the Software.
    15  //
    16  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    17  // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    18  // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    19  // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    20  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    21  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    22  // THE SOFTWARE.
    23  
    24  package test
    25  
    26  import (
    27  	errors "errors"
    28  	fmt "fmt"
    29  	multierr "go.uber.org/multierr"
    30  	stream "go.uber.org/thriftrw/protocol/stream"
    31  	thriftreflect "go.uber.org/thriftrw/thriftreflect"
    32  	wire "go.uber.org/thriftrw/wire"
    33  	zapcore "go.uber.org/zap/zapcore"
    34  	strings "strings"
    35  )
    36  
    37  type ExceptionWithCode struct {
    38  	Val string `json:"val,required"`
    39  }
    40  
    41  // ToWire translates a ExceptionWithCode struct into a Thrift-level intermediate
    42  // representation. This intermediate representation may be serialized
    43  // into bytes using a ThriftRW protocol implementation.
    44  //
    45  // An error is returned if the struct or any of its fields failed to
    46  // validate.
    47  //
    48  //   x, err := v.ToWire()
    49  //   if err != nil {
    50  //     return err
    51  //   }
    52  //
    53  //   if err := binaryProtocol.Encode(x, writer); err != nil {
    54  //     return err
    55  //   }
    56  func (v *ExceptionWithCode) ToWire() (wire.Value, error) {
    57  	var (
    58  		fields [1]wire.Field
    59  		i      int = 0
    60  		w      wire.Value
    61  		err    error
    62  	)
    63  
    64  	w, err = wire.NewValueString(v.Val), error(nil)
    65  	if err != nil {
    66  		return w, err
    67  	}
    68  	fields[i] = wire.Field{ID: 1, Value: w}
    69  	i++
    70  
    71  	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
    72  }
    73  
    74  // FromWire deserializes a ExceptionWithCode struct from its Thrift-level
    75  // representation. The Thrift-level representation may be obtained
    76  // from a ThriftRW protocol implementation.
    77  //
    78  // An error is returned if we were unable to build a ExceptionWithCode struct
    79  // from the provided intermediate representation.
    80  //
    81  //   x, err := binaryProtocol.Decode(reader, wire.TStruct)
    82  //   if err != nil {
    83  //     return nil, err
    84  //   }
    85  //
    86  //   var v ExceptionWithCode
    87  //   if err := v.FromWire(x); err != nil {
    88  //     return nil, err
    89  //   }
    90  //   return &v, nil
    91  func (v *ExceptionWithCode) FromWire(w wire.Value) error {
    92  	var err error
    93  
    94  	valIsSet := false
    95  
    96  	for _, field := range w.GetStruct().Fields {
    97  		switch field.ID {
    98  		case 1:
    99  			if field.Value.Type() == wire.TBinary {
   100  				v.Val, err = field.Value.GetString(), error(nil)
   101  				if err != nil {
   102  					return err
   103  				}
   104  				valIsSet = true
   105  			}
   106  		}
   107  	}
   108  
   109  	if !valIsSet {
   110  		return errors.New("field Val of ExceptionWithCode is required")
   111  	}
   112  
   113  	return nil
   114  }
   115  
   116  // Encode serializes a ExceptionWithCode struct directly into bytes, without going
   117  // through an intermediary type.
   118  //
   119  // An error is returned if a ExceptionWithCode struct could not be encoded.
   120  func (v *ExceptionWithCode) Encode(sw stream.Writer) error {
   121  	if err := sw.WriteStructBegin(); err != nil {
   122  		return err
   123  	}
   124  
   125  	if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
   126  		return err
   127  	}
   128  	if err := sw.WriteString(v.Val); err != nil {
   129  		return err
   130  	}
   131  	if err := sw.WriteFieldEnd(); err != nil {
   132  		return err
   133  	}
   134  
   135  	return sw.WriteStructEnd()
   136  }
   137  
   138  // Decode deserializes a ExceptionWithCode struct directly from its Thrift-level
   139  // representation, without going through an intemediary type.
   140  //
   141  // An error is returned if a ExceptionWithCode struct could not be generated from the wire
   142  // representation.
   143  func (v *ExceptionWithCode) Decode(sr stream.Reader) error {
   144  
   145  	valIsSet := false
   146  
   147  	if err := sr.ReadStructBegin(); err != nil {
   148  		return err
   149  	}
   150  
   151  	fh, ok, err := sr.ReadFieldBegin()
   152  	if err != nil {
   153  		return err
   154  	}
   155  
   156  	for ok {
   157  		switch {
   158  		case fh.ID == 1 && fh.Type == wire.TBinary:
   159  			v.Val, err = sr.ReadString()
   160  			if err != nil {
   161  				return err
   162  			}
   163  			valIsSet = true
   164  		default:
   165  			if err := sr.Skip(fh.Type); err != nil {
   166  				return err
   167  			}
   168  		}
   169  
   170  		if err := sr.ReadFieldEnd(); err != nil {
   171  			return err
   172  		}
   173  
   174  		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
   175  			return err
   176  		}
   177  	}
   178  
   179  	if err := sr.ReadStructEnd(); err != nil {
   180  		return err
   181  	}
   182  
   183  	if !valIsSet {
   184  		return errors.New("field Val of ExceptionWithCode is required")
   185  	}
   186  
   187  	return nil
   188  }
   189  
   190  // String returns a readable string representation of a ExceptionWithCode
   191  // struct.
   192  func (v *ExceptionWithCode) String() string {
   193  	if v == nil {
   194  		return "<nil>"
   195  	}
   196  
   197  	var fields [1]string
   198  	i := 0
   199  	fields[i] = fmt.Sprintf("Val: %v", v.Val)
   200  	i++
   201  
   202  	return fmt.Sprintf("ExceptionWithCode{%v}", strings.Join(fields[:i], ", "))
   203  }
   204  
   205  // ErrorName is the name of this type as defined in the Thrift
   206  // file.
   207  func (*ExceptionWithCode) ErrorName() string {
   208  	return "ExceptionWithCode"
   209  }
   210  
   211  // Equals returns true if all the fields of this ExceptionWithCode match the
   212  // provided ExceptionWithCode.
   213  //
   214  // This function performs a deep comparison.
   215  func (v *ExceptionWithCode) Equals(rhs *ExceptionWithCode) bool {
   216  	if v == nil {
   217  		return rhs == nil
   218  	} else if rhs == nil {
   219  		return false
   220  	}
   221  	if !(v.Val == rhs.Val) {
   222  		return false
   223  	}
   224  
   225  	return true
   226  }
   227  
   228  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
   229  // fast logging of ExceptionWithCode.
   230  func (v *ExceptionWithCode) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
   231  	if v == nil {
   232  		return nil
   233  	}
   234  	enc.AddString("val", v.Val)
   235  	return err
   236  }
   237  
   238  // GetVal returns the value of Val if it is set or its
   239  // zero value if it is unset.
   240  func (v *ExceptionWithCode) GetVal() (o string) {
   241  	if v != nil {
   242  		o = v.Val
   243  	}
   244  	return
   245  }
   246  
   247  func (v *ExceptionWithCode) Error() string {
   248  	return v.String()
   249  }
   250  
   251  type ExceptionWithoutCode struct {
   252  	Val string `json:"val,required"`
   253  }
   254  
   255  // ToWire translates a ExceptionWithoutCode struct into a Thrift-level intermediate
   256  // representation. This intermediate representation may be serialized
   257  // into bytes using a ThriftRW protocol implementation.
   258  //
   259  // An error is returned if the struct or any of its fields failed to
   260  // validate.
   261  //
   262  //   x, err := v.ToWire()
   263  //   if err != nil {
   264  //     return err
   265  //   }
   266  //
   267  //   if err := binaryProtocol.Encode(x, writer); err != nil {
   268  //     return err
   269  //   }
   270  func (v *ExceptionWithoutCode) ToWire() (wire.Value, error) {
   271  	var (
   272  		fields [1]wire.Field
   273  		i      int = 0
   274  		w      wire.Value
   275  		err    error
   276  	)
   277  
   278  	w, err = wire.NewValueString(v.Val), error(nil)
   279  	if err != nil {
   280  		return w, err
   281  	}
   282  	fields[i] = wire.Field{ID: 1, Value: w}
   283  	i++
   284  
   285  	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
   286  }
   287  
   288  // FromWire deserializes a ExceptionWithoutCode struct from its Thrift-level
   289  // representation. The Thrift-level representation may be obtained
   290  // from a ThriftRW protocol implementation.
   291  //
   292  // An error is returned if we were unable to build a ExceptionWithoutCode struct
   293  // from the provided intermediate representation.
   294  //
   295  //   x, err := binaryProtocol.Decode(reader, wire.TStruct)
   296  //   if err != nil {
   297  //     return nil, err
   298  //   }
   299  //
   300  //   var v ExceptionWithoutCode
   301  //   if err := v.FromWire(x); err != nil {
   302  //     return nil, err
   303  //   }
   304  //   return &v, nil
   305  func (v *ExceptionWithoutCode) FromWire(w wire.Value) error {
   306  	var err error
   307  
   308  	valIsSet := false
   309  
   310  	for _, field := range w.GetStruct().Fields {
   311  		switch field.ID {
   312  		case 1:
   313  			if field.Value.Type() == wire.TBinary {
   314  				v.Val, err = field.Value.GetString(), error(nil)
   315  				if err != nil {
   316  					return err
   317  				}
   318  				valIsSet = true
   319  			}
   320  		}
   321  	}
   322  
   323  	if !valIsSet {
   324  		return errors.New("field Val of ExceptionWithoutCode is required")
   325  	}
   326  
   327  	return nil
   328  }
   329  
   330  // Encode serializes a ExceptionWithoutCode struct directly into bytes, without going
   331  // through an intermediary type.
   332  //
   333  // An error is returned if a ExceptionWithoutCode struct could not be encoded.
   334  func (v *ExceptionWithoutCode) Encode(sw stream.Writer) error {
   335  	if err := sw.WriteStructBegin(); err != nil {
   336  		return err
   337  	}
   338  
   339  	if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
   340  		return err
   341  	}
   342  	if err := sw.WriteString(v.Val); err != nil {
   343  		return err
   344  	}
   345  	if err := sw.WriteFieldEnd(); err != nil {
   346  		return err
   347  	}
   348  
   349  	return sw.WriteStructEnd()
   350  }
   351  
   352  // Decode deserializes a ExceptionWithoutCode struct directly from its Thrift-level
   353  // representation, without going through an intemediary type.
   354  //
   355  // An error is returned if a ExceptionWithoutCode struct could not be generated from the wire
   356  // representation.
   357  func (v *ExceptionWithoutCode) Decode(sr stream.Reader) error {
   358  
   359  	valIsSet := false
   360  
   361  	if err := sr.ReadStructBegin(); err != nil {
   362  		return err
   363  	}
   364  
   365  	fh, ok, err := sr.ReadFieldBegin()
   366  	if err != nil {
   367  		return err
   368  	}
   369  
   370  	for ok {
   371  		switch {
   372  		case fh.ID == 1 && fh.Type == wire.TBinary:
   373  			v.Val, err = sr.ReadString()
   374  			if err != nil {
   375  				return err
   376  			}
   377  			valIsSet = true
   378  		default:
   379  			if err := sr.Skip(fh.Type); err != nil {
   380  				return err
   381  			}
   382  		}
   383  
   384  		if err := sr.ReadFieldEnd(); err != nil {
   385  			return err
   386  		}
   387  
   388  		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
   389  			return err
   390  		}
   391  	}
   392  
   393  	if err := sr.ReadStructEnd(); err != nil {
   394  		return err
   395  	}
   396  
   397  	if !valIsSet {
   398  		return errors.New("field Val of ExceptionWithoutCode is required")
   399  	}
   400  
   401  	return nil
   402  }
   403  
   404  // String returns a readable string representation of a ExceptionWithoutCode
   405  // struct.
   406  func (v *ExceptionWithoutCode) String() string {
   407  	if v == nil {
   408  		return "<nil>"
   409  	}
   410  
   411  	var fields [1]string
   412  	i := 0
   413  	fields[i] = fmt.Sprintf("Val: %v", v.Val)
   414  	i++
   415  
   416  	return fmt.Sprintf("ExceptionWithoutCode{%v}", strings.Join(fields[:i], ", "))
   417  }
   418  
   419  // ErrorName is the name of this type as defined in the Thrift
   420  // file.
   421  func (*ExceptionWithoutCode) ErrorName() string {
   422  	return "ExceptionWithoutCode"
   423  }
   424  
   425  // Equals returns true if all the fields of this ExceptionWithoutCode match the
   426  // provided ExceptionWithoutCode.
   427  //
   428  // This function performs a deep comparison.
   429  func (v *ExceptionWithoutCode) Equals(rhs *ExceptionWithoutCode) bool {
   430  	if v == nil {
   431  		return rhs == nil
   432  	} else if rhs == nil {
   433  		return false
   434  	}
   435  	if !(v.Val == rhs.Val) {
   436  		return false
   437  	}
   438  
   439  	return true
   440  }
   441  
   442  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
   443  // fast logging of ExceptionWithoutCode.
   444  func (v *ExceptionWithoutCode) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
   445  	if v == nil {
   446  		return nil
   447  	}
   448  	enc.AddString("val", v.Val)
   449  	return err
   450  }
   451  
   452  // GetVal returns the value of Val if it is set or its
   453  // zero value if it is unset.
   454  func (v *ExceptionWithoutCode) GetVal() (o string) {
   455  	if v != nil {
   456  		o = v.Val
   457  	}
   458  	return
   459  }
   460  
   461  func (v *ExceptionWithoutCode) Error() string {
   462  	return v.String()
   463  }
   464  
   465  // ThriftModule represents the IDL file used to generate this package.
   466  var ThriftModule = &thriftreflect.ThriftModule{
   467  	Name:     "test",
   468  	Package:  "go.uber.org/yarpc/encoding/thrift/internal/observabilitytest/test",
   469  	FilePath: "test.thrift",
   470  	SHA1:     "3c501036fe37f678648dd479c821bc57aa17b7d1",
   471  	Raw:      rawIDL,
   472  }
   473  
   474  const rawIDL = "exception ExceptionWithCode {\n    1: required string val\n} (\n    rpc.code = \"DATA_LOSS\" // server error\n)\n\nexception ExceptionWithoutCode {\n    1: required string val\n}\n\nservice TestService  {\n    string Call(1: required string key) throws (\n      1: ExceptionWithCode exCode,\n      2: ExceptionWithoutCode exNoCode,\n    )\n}\n"
   475  
   476  // TestService_Call_Args represents the arguments for the TestService.Call function.
   477  //
   478  // The arguments for Call are sent and received over the wire as this struct.
   479  type TestService_Call_Args struct {
   480  	Key string `json:"key,required"`
   481  }
   482  
   483  // ToWire translates a TestService_Call_Args struct into a Thrift-level intermediate
   484  // representation. This intermediate representation may be serialized
   485  // into bytes using a ThriftRW protocol implementation.
   486  //
   487  // An error is returned if the struct or any of its fields failed to
   488  // validate.
   489  //
   490  //   x, err := v.ToWire()
   491  //   if err != nil {
   492  //     return err
   493  //   }
   494  //
   495  //   if err := binaryProtocol.Encode(x, writer); err != nil {
   496  //     return err
   497  //   }
   498  func (v *TestService_Call_Args) ToWire() (wire.Value, error) {
   499  	var (
   500  		fields [1]wire.Field
   501  		i      int = 0
   502  		w      wire.Value
   503  		err    error
   504  	)
   505  
   506  	w, err = wire.NewValueString(v.Key), error(nil)
   507  	if err != nil {
   508  		return w, err
   509  	}
   510  	fields[i] = wire.Field{ID: 1, Value: w}
   511  	i++
   512  
   513  	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
   514  }
   515  
   516  // FromWire deserializes a TestService_Call_Args struct from its Thrift-level
   517  // representation. The Thrift-level representation may be obtained
   518  // from a ThriftRW protocol implementation.
   519  //
   520  // An error is returned if we were unable to build a TestService_Call_Args struct
   521  // from the provided intermediate representation.
   522  //
   523  //   x, err := binaryProtocol.Decode(reader, wire.TStruct)
   524  //   if err != nil {
   525  //     return nil, err
   526  //   }
   527  //
   528  //   var v TestService_Call_Args
   529  //   if err := v.FromWire(x); err != nil {
   530  //     return nil, err
   531  //   }
   532  //   return &v, nil
   533  func (v *TestService_Call_Args) FromWire(w wire.Value) error {
   534  	var err error
   535  
   536  	keyIsSet := false
   537  
   538  	for _, field := range w.GetStruct().Fields {
   539  		switch field.ID {
   540  		case 1:
   541  			if field.Value.Type() == wire.TBinary {
   542  				v.Key, err = field.Value.GetString(), error(nil)
   543  				if err != nil {
   544  					return err
   545  				}
   546  				keyIsSet = true
   547  			}
   548  		}
   549  	}
   550  
   551  	if !keyIsSet {
   552  		return errors.New("field Key of TestService_Call_Args is required")
   553  	}
   554  
   555  	return nil
   556  }
   557  
   558  // Encode serializes a TestService_Call_Args struct directly into bytes, without going
   559  // through an intermediary type.
   560  //
   561  // An error is returned if a TestService_Call_Args struct could not be encoded.
   562  func (v *TestService_Call_Args) Encode(sw stream.Writer) error {
   563  	if err := sw.WriteStructBegin(); err != nil {
   564  		return err
   565  	}
   566  
   567  	if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TBinary}); err != nil {
   568  		return err
   569  	}
   570  	if err := sw.WriteString(v.Key); err != nil {
   571  		return err
   572  	}
   573  	if err := sw.WriteFieldEnd(); err != nil {
   574  		return err
   575  	}
   576  
   577  	return sw.WriteStructEnd()
   578  }
   579  
   580  // Decode deserializes a TestService_Call_Args struct directly from its Thrift-level
   581  // representation, without going through an intemediary type.
   582  //
   583  // An error is returned if a TestService_Call_Args struct could not be generated from the wire
   584  // representation.
   585  func (v *TestService_Call_Args) Decode(sr stream.Reader) error {
   586  
   587  	keyIsSet := false
   588  
   589  	if err := sr.ReadStructBegin(); err != nil {
   590  		return err
   591  	}
   592  
   593  	fh, ok, err := sr.ReadFieldBegin()
   594  	if err != nil {
   595  		return err
   596  	}
   597  
   598  	for ok {
   599  		switch {
   600  		case fh.ID == 1 && fh.Type == wire.TBinary:
   601  			v.Key, err = sr.ReadString()
   602  			if err != nil {
   603  				return err
   604  			}
   605  			keyIsSet = true
   606  		default:
   607  			if err := sr.Skip(fh.Type); err != nil {
   608  				return err
   609  			}
   610  		}
   611  
   612  		if err := sr.ReadFieldEnd(); err != nil {
   613  			return err
   614  		}
   615  
   616  		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
   617  			return err
   618  		}
   619  	}
   620  
   621  	if err := sr.ReadStructEnd(); err != nil {
   622  		return err
   623  	}
   624  
   625  	if !keyIsSet {
   626  		return errors.New("field Key of TestService_Call_Args is required")
   627  	}
   628  
   629  	return nil
   630  }
   631  
   632  // String returns a readable string representation of a TestService_Call_Args
   633  // struct.
   634  func (v *TestService_Call_Args) String() string {
   635  	if v == nil {
   636  		return "<nil>"
   637  	}
   638  
   639  	var fields [1]string
   640  	i := 0
   641  	fields[i] = fmt.Sprintf("Key: %v", v.Key)
   642  	i++
   643  
   644  	return fmt.Sprintf("TestService_Call_Args{%v}", strings.Join(fields[:i], ", "))
   645  }
   646  
   647  // Equals returns true if all the fields of this TestService_Call_Args match the
   648  // provided TestService_Call_Args.
   649  //
   650  // This function performs a deep comparison.
   651  func (v *TestService_Call_Args) Equals(rhs *TestService_Call_Args) bool {
   652  	if v == nil {
   653  		return rhs == nil
   654  	} else if rhs == nil {
   655  		return false
   656  	}
   657  	if !(v.Key == rhs.Key) {
   658  		return false
   659  	}
   660  
   661  	return true
   662  }
   663  
   664  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
   665  // fast logging of TestService_Call_Args.
   666  func (v *TestService_Call_Args) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
   667  	if v == nil {
   668  		return nil
   669  	}
   670  	enc.AddString("key", v.Key)
   671  	return err
   672  }
   673  
   674  // GetKey returns the value of Key if it is set or its
   675  // zero value if it is unset.
   676  func (v *TestService_Call_Args) GetKey() (o string) {
   677  	if v != nil {
   678  		o = v.Key
   679  	}
   680  	return
   681  }
   682  
   683  // MethodName returns the name of the Thrift function as specified in
   684  // the IDL, for which this struct represent the arguments.
   685  //
   686  // This will always be "Call" for this struct.
   687  func (v *TestService_Call_Args) MethodName() string {
   688  	return "Call"
   689  }
   690  
   691  // EnvelopeType returns the kind of value inside this struct.
   692  //
   693  // This will always be Call for this struct.
   694  func (v *TestService_Call_Args) EnvelopeType() wire.EnvelopeType {
   695  	return wire.Call
   696  }
   697  
   698  // TestService_Call_Helper provides functions that aid in handling the
   699  // parameters and return values of the TestService.Call
   700  // function.
   701  var TestService_Call_Helper = struct {
   702  	// Args accepts the parameters of Call in-order and returns
   703  	// the arguments struct for the function.
   704  	Args func(
   705  		key string,
   706  	) *TestService_Call_Args
   707  
   708  	// IsException returns true if the given error can be thrown
   709  	// by Call.
   710  	//
   711  	// An error can be thrown by Call only if the
   712  	// corresponding exception type was mentioned in the 'throws'
   713  	// section for it in the Thrift file.
   714  	IsException func(error) bool
   715  
   716  	// WrapResponse returns the result struct for Call
   717  	// given its return value and error.
   718  	//
   719  	// This allows mapping values and errors returned by
   720  	// Call into a serializable result struct.
   721  	// WrapResponse returns a non-nil error if the provided
   722  	// error cannot be thrown by Call
   723  	//
   724  	//   value, err := Call(args)
   725  	//   result, err := TestService_Call_Helper.WrapResponse(value, err)
   726  	//   if err != nil {
   727  	//     return fmt.Errorf("unexpected error from Call: %v", err)
   728  	//   }
   729  	//   serialize(result)
   730  	WrapResponse func(string, error) (*TestService_Call_Result, error)
   731  
   732  	// UnwrapResponse takes the result struct for Call
   733  	// and returns the value or error returned by it.
   734  	//
   735  	// The error is non-nil only if Call threw an
   736  	// exception.
   737  	//
   738  	//   result := deserialize(bytes)
   739  	//   value, err := TestService_Call_Helper.UnwrapResponse(result)
   740  	UnwrapResponse func(*TestService_Call_Result) (string, error)
   741  }{}
   742  
   743  func init() {
   744  	TestService_Call_Helper.Args = func(
   745  		key string,
   746  	) *TestService_Call_Args {
   747  		return &TestService_Call_Args{
   748  			Key: key,
   749  		}
   750  	}
   751  
   752  	TestService_Call_Helper.IsException = func(err error) bool {
   753  		switch err.(type) {
   754  		case *ExceptionWithCode:
   755  			return true
   756  		case *ExceptionWithoutCode:
   757  			return true
   758  		default:
   759  			return false
   760  		}
   761  	}
   762  
   763  	TestService_Call_Helper.WrapResponse = func(success string, err error) (*TestService_Call_Result, error) {
   764  		if err == nil {
   765  			return &TestService_Call_Result{Success: &success}, nil
   766  		}
   767  
   768  		switch e := err.(type) {
   769  		case *ExceptionWithCode:
   770  			if e == nil {
   771  				return nil, errors.New("WrapResponse received non-nil error type with nil value for TestService_Call_Result.ExCode")
   772  			}
   773  			return &TestService_Call_Result{ExCode: e}, nil
   774  		case *ExceptionWithoutCode:
   775  			if e == nil {
   776  				return nil, errors.New("WrapResponse received non-nil error type with nil value for TestService_Call_Result.ExNoCode")
   777  			}
   778  			return &TestService_Call_Result{ExNoCode: e}, nil
   779  		}
   780  
   781  		return nil, err
   782  	}
   783  	TestService_Call_Helper.UnwrapResponse = func(result *TestService_Call_Result) (success string, err error) {
   784  		if result.ExCode != nil {
   785  			err = result.ExCode
   786  			return
   787  		}
   788  		if result.ExNoCode != nil {
   789  			err = result.ExNoCode
   790  			return
   791  		}
   792  
   793  		if result.Success != nil {
   794  			success = *result.Success
   795  			return
   796  		}
   797  
   798  		err = errors.New("expected a non-void result")
   799  		return
   800  	}
   801  
   802  }
   803  
   804  // TestService_Call_Result represents the result of a TestService.Call function call.
   805  //
   806  // The result of a Call execution is sent and received over the wire as this struct.
   807  //
   808  // Success is set only if the function did not throw an exception.
   809  type TestService_Call_Result struct {
   810  	// Value returned by Call after a successful execution.
   811  	Success  *string               `json:"success,omitempty"`
   812  	ExCode   *ExceptionWithCode    `json:"exCode,omitempty"`
   813  	ExNoCode *ExceptionWithoutCode `json:"exNoCode,omitempty"`
   814  }
   815  
   816  // ToWire translates a TestService_Call_Result struct into a Thrift-level intermediate
   817  // representation. This intermediate representation may be serialized
   818  // into bytes using a ThriftRW protocol implementation.
   819  //
   820  // An error is returned if the struct or any of its fields failed to
   821  // validate.
   822  //
   823  //   x, err := v.ToWire()
   824  //   if err != nil {
   825  //     return err
   826  //   }
   827  //
   828  //   if err := binaryProtocol.Encode(x, writer); err != nil {
   829  //     return err
   830  //   }
   831  func (v *TestService_Call_Result) ToWire() (wire.Value, error) {
   832  	var (
   833  		fields [3]wire.Field
   834  		i      int = 0
   835  		w      wire.Value
   836  		err    error
   837  	)
   838  
   839  	if v.Success != nil {
   840  		w, err = wire.NewValueString(*(v.Success)), error(nil)
   841  		if err != nil {
   842  			return w, err
   843  		}
   844  		fields[i] = wire.Field{ID: 0, Value: w}
   845  		i++
   846  	}
   847  	if v.ExCode != nil {
   848  		w, err = v.ExCode.ToWire()
   849  		if err != nil {
   850  			return w, err
   851  		}
   852  		fields[i] = wire.Field{ID: 1, Value: w}
   853  		i++
   854  	}
   855  	if v.ExNoCode != nil {
   856  		w, err = v.ExNoCode.ToWire()
   857  		if err != nil {
   858  			return w, err
   859  		}
   860  		fields[i] = wire.Field{ID: 2, Value: w}
   861  		i++
   862  	}
   863  
   864  	if i != 1 {
   865  		return wire.Value{}, fmt.Errorf("TestService_Call_Result should have exactly one field: got %v fields", i)
   866  	}
   867  
   868  	return wire.NewValueStruct(wire.Struct{Fields: fields[:i]}), nil
   869  }
   870  
   871  func _ExceptionWithCode_Read(w wire.Value) (*ExceptionWithCode, error) {
   872  	var v ExceptionWithCode
   873  	err := v.FromWire(w)
   874  	return &v, err
   875  }
   876  
   877  func _ExceptionWithoutCode_Read(w wire.Value) (*ExceptionWithoutCode, error) {
   878  	var v ExceptionWithoutCode
   879  	err := v.FromWire(w)
   880  	return &v, err
   881  }
   882  
   883  // FromWire deserializes a TestService_Call_Result struct from its Thrift-level
   884  // representation. The Thrift-level representation may be obtained
   885  // from a ThriftRW protocol implementation.
   886  //
   887  // An error is returned if we were unable to build a TestService_Call_Result struct
   888  // from the provided intermediate representation.
   889  //
   890  //   x, err := binaryProtocol.Decode(reader, wire.TStruct)
   891  //   if err != nil {
   892  //     return nil, err
   893  //   }
   894  //
   895  //   var v TestService_Call_Result
   896  //   if err := v.FromWire(x); err != nil {
   897  //     return nil, err
   898  //   }
   899  //   return &v, nil
   900  func (v *TestService_Call_Result) FromWire(w wire.Value) error {
   901  	var err error
   902  
   903  	for _, field := range w.GetStruct().Fields {
   904  		switch field.ID {
   905  		case 0:
   906  			if field.Value.Type() == wire.TBinary {
   907  				var x string
   908  				x, err = field.Value.GetString(), error(nil)
   909  				v.Success = &x
   910  				if err != nil {
   911  					return err
   912  				}
   913  
   914  			}
   915  		case 1:
   916  			if field.Value.Type() == wire.TStruct {
   917  				v.ExCode, err = _ExceptionWithCode_Read(field.Value)
   918  				if err != nil {
   919  					return err
   920  				}
   921  
   922  			}
   923  		case 2:
   924  			if field.Value.Type() == wire.TStruct {
   925  				v.ExNoCode, err = _ExceptionWithoutCode_Read(field.Value)
   926  				if err != nil {
   927  					return err
   928  				}
   929  
   930  			}
   931  		}
   932  	}
   933  
   934  	count := 0
   935  	if v.Success != nil {
   936  		count++
   937  	}
   938  	if v.ExCode != nil {
   939  		count++
   940  	}
   941  	if v.ExNoCode != nil {
   942  		count++
   943  	}
   944  	if count != 1 {
   945  		return fmt.Errorf("TestService_Call_Result should have exactly one field: got %v fields", count)
   946  	}
   947  
   948  	return nil
   949  }
   950  
   951  // Encode serializes a TestService_Call_Result struct directly into bytes, without going
   952  // through an intermediary type.
   953  //
   954  // An error is returned if a TestService_Call_Result struct could not be encoded.
   955  func (v *TestService_Call_Result) Encode(sw stream.Writer) error {
   956  	if err := sw.WriteStructBegin(); err != nil {
   957  		return err
   958  	}
   959  
   960  	if v.Success != nil {
   961  		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 0, Type: wire.TBinary}); err != nil {
   962  			return err
   963  		}
   964  		if err := sw.WriteString(*(v.Success)); err != nil {
   965  			return err
   966  		}
   967  		if err := sw.WriteFieldEnd(); err != nil {
   968  			return err
   969  		}
   970  	}
   971  
   972  	if v.ExCode != nil {
   973  		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 1, Type: wire.TStruct}); err != nil {
   974  			return err
   975  		}
   976  		if err := v.ExCode.Encode(sw); err != nil {
   977  			return err
   978  		}
   979  		if err := sw.WriteFieldEnd(); err != nil {
   980  			return err
   981  		}
   982  	}
   983  
   984  	if v.ExNoCode != nil {
   985  		if err := sw.WriteFieldBegin(stream.FieldHeader{ID: 2, Type: wire.TStruct}); err != nil {
   986  			return err
   987  		}
   988  		if err := v.ExNoCode.Encode(sw); err != nil {
   989  			return err
   990  		}
   991  		if err := sw.WriteFieldEnd(); err != nil {
   992  			return err
   993  		}
   994  	}
   995  
   996  	count := 0
   997  	if v.Success != nil {
   998  		count++
   999  	}
  1000  	if v.ExCode != nil {
  1001  		count++
  1002  	}
  1003  	if v.ExNoCode != nil {
  1004  		count++
  1005  	}
  1006  
  1007  	if count != 1 {
  1008  		return fmt.Errorf("TestService_Call_Result should have exactly one field: got %v fields", count)
  1009  	}
  1010  
  1011  	return sw.WriteStructEnd()
  1012  }
  1013  
  1014  func _ExceptionWithCode_Decode(sr stream.Reader) (*ExceptionWithCode, error) {
  1015  	var v ExceptionWithCode
  1016  	err := v.Decode(sr)
  1017  	return &v, err
  1018  }
  1019  
  1020  func _ExceptionWithoutCode_Decode(sr stream.Reader) (*ExceptionWithoutCode, error) {
  1021  	var v ExceptionWithoutCode
  1022  	err := v.Decode(sr)
  1023  	return &v, err
  1024  }
  1025  
  1026  // Decode deserializes a TestService_Call_Result struct directly from its Thrift-level
  1027  // representation, without going through an intemediary type.
  1028  //
  1029  // An error is returned if a TestService_Call_Result struct could not be generated from the wire
  1030  // representation.
  1031  func (v *TestService_Call_Result) Decode(sr stream.Reader) error {
  1032  
  1033  	if err := sr.ReadStructBegin(); err != nil {
  1034  		return err
  1035  	}
  1036  
  1037  	fh, ok, err := sr.ReadFieldBegin()
  1038  	if err != nil {
  1039  		return err
  1040  	}
  1041  
  1042  	for ok {
  1043  		switch {
  1044  		case fh.ID == 0 && fh.Type == wire.TBinary:
  1045  			var x string
  1046  			x, err = sr.ReadString()
  1047  			v.Success = &x
  1048  			if err != nil {
  1049  				return err
  1050  			}
  1051  
  1052  		case fh.ID == 1 && fh.Type == wire.TStruct:
  1053  			v.ExCode, err = _ExceptionWithCode_Decode(sr)
  1054  			if err != nil {
  1055  				return err
  1056  			}
  1057  
  1058  		case fh.ID == 2 && fh.Type == wire.TStruct:
  1059  			v.ExNoCode, err = _ExceptionWithoutCode_Decode(sr)
  1060  			if err != nil {
  1061  				return err
  1062  			}
  1063  
  1064  		default:
  1065  			if err := sr.Skip(fh.Type); err != nil {
  1066  				return err
  1067  			}
  1068  		}
  1069  
  1070  		if err := sr.ReadFieldEnd(); err != nil {
  1071  			return err
  1072  		}
  1073  
  1074  		if fh, ok, err = sr.ReadFieldBegin(); err != nil {
  1075  			return err
  1076  		}
  1077  	}
  1078  
  1079  	if err := sr.ReadStructEnd(); err != nil {
  1080  		return err
  1081  	}
  1082  
  1083  	count := 0
  1084  	if v.Success != nil {
  1085  		count++
  1086  	}
  1087  	if v.ExCode != nil {
  1088  		count++
  1089  	}
  1090  	if v.ExNoCode != nil {
  1091  		count++
  1092  	}
  1093  	if count != 1 {
  1094  		return fmt.Errorf("TestService_Call_Result should have exactly one field: got %v fields", count)
  1095  	}
  1096  
  1097  	return nil
  1098  }
  1099  
  1100  // String returns a readable string representation of a TestService_Call_Result
  1101  // struct.
  1102  func (v *TestService_Call_Result) String() string {
  1103  	if v == nil {
  1104  		return "<nil>"
  1105  	}
  1106  
  1107  	var fields [3]string
  1108  	i := 0
  1109  	if v.Success != nil {
  1110  		fields[i] = fmt.Sprintf("Success: %v", *(v.Success))
  1111  		i++
  1112  	}
  1113  	if v.ExCode != nil {
  1114  		fields[i] = fmt.Sprintf("ExCode: %v", v.ExCode)
  1115  		i++
  1116  	}
  1117  	if v.ExNoCode != nil {
  1118  		fields[i] = fmt.Sprintf("ExNoCode: %v", v.ExNoCode)
  1119  		i++
  1120  	}
  1121  
  1122  	return fmt.Sprintf("TestService_Call_Result{%v}", strings.Join(fields[:i], ", "))
  1123  }
  1124  
  1125  func _String_EqualsPtr(lhs, rhs *string) bool {
  1126  	if lhs != nil && rhs != nil {
  1127  
  1128  		x := *lhs
  1129  		y := *rhs
  1130  		return (x == y)
  1131  	}
  1132  	return lhs == nil && rhs == nil
  1133  }
  1134  
  1135  // Equals returns true if all the fields of this TestService_Call_Result match the
  1136  // provided TestService_Call_Result.
  1137  //
  1138  // This function performs a deep comparison.
  1139  func (v *TestService_Call_Result) Equals(rhs *TestService_Call_Result) bool {
  1140  	if v == nil {
  1141  		return rhs == nil
  1142  	} else if rhs == nil {
  1143  		return false
  1144  	}
  1145  	if !_String_EqualsPtr(v.Success, rhs.Success) {
  1146  		return false
  1147  	}
  1148  	if !((v.ExCode == nil && rhs.ExCode == nil) || (v.ExCode != nil && rhs.ExCode != nil && v.ExCode.Equals(rhs.ExCode))) {
  1149  		return false
  1150  	}
  1151  	if !((v.ExNoCode == nil && rhs.ExNoCode == nil) || (v.ExNoCode != nil && rhs.ExNoCode != nil && v.ExNoCode.Equals(rhs.ExNoCode))) {
  1152  		return false
  1153  	}
  1154  
  1155  	return true
  1156  }
  1157  
  1158  // MarshalLogObject implements zapcore.ObjectMarshaler, enabling
  1159  // fast logging of TestService_Call_Result.
  1160  func (v *TestService_Call_Result) MarshalLogObject(enc zapcore.ObjectEncoder) (err error) {
  1161  	if v == nil {
  1162  		return nil
  1163  	}
  1164  	if v.Success != nil {
  1165  		enc.AddString("success", *v.Success)
  1166  	}
  1167  	if v.ExCode != nil {
  1168  		err = multierr.Append(err, enc.AddObject("exCode", v.ExCode))
  1169  	}
  1170  	if v.ExNoCode != nil {
  1171  		err = multierr.Append(err, enc.AddObject("exNoCode", v.ExNoCode))
  1172  	}
  1173  	return err
  1174  }
  1175  
  1176  // GetSuccess returns the value of Success if it is set or its
  1177  // zero value if it is unset.
  1178  func (v *TestService_Call_Result) GetSuccess() (o string) {
  1179  	if v != nil && v.Success != nil {
  1180  		return *v.Success
  1181  	}
  1182  
  1183  	return
  1184  }
  1185  
  1186  // IsSetSuccess returns true if Success is not nil.
  1187  func (v *TestService_Call_Result) IsSetSuccess() bool {
  1188  	return v != nil && v.Success != nil
  1189  }
  1190  
  1191  // GetExCode returns the value of ExCode if it is set or its
  1192  // zero value if it is unset.
  1193  func (v *TestService_Call_Result) GetExCode() (o *ExceptionWithCode) {
  1194  	if v != nil && v.ExCode != nil {
  1195  		return v.ExCode
  1196  	}
  1197  
  1198  	return
  1199  }
  1200  
  1201  // IsSetExCode returns true if ExCode is not nil.
  1202  func (v *TestService_Call_Result) IsSetExCode() bool {
  1203  	return v != nil && v.ExCode != nil
  1204  }
  1205  
  1206  // GetExNoCode returns the value of ExNoCode if it is set or its
  1207  // zero value if it is unset.
  1208  func (v *TestService_Call_Result) GetExNoCode() (o *ExceptionWithoutCode) {
  1209  	if v != nil && v.ExNoCode != nil {
  1210  		return v.ExNoCode
  1211  	}
  1212  
  1213  	return
  1214  }
  1215  
  1216  // IsSetExNoCode returns true if ExNoCode is not nil.
  1217  func (v *TestService_Call_Result) IsSetExNoCode() bool {
  1218  	return v != nil && v.ExNoCode != nil
  1219  }
  1220  
  1221  // MethodName returns the name of the Thrift function as specified in
  1222  // the IDL, for which this struct represent the result.
  1223  //
  1224  // This will always be "Call" for this struct.
  1225  func (v *TestService_Call_Result) MethodName() string {
  1226  	return "Call"
  1227  }
  1228  
  1229  // EnvelopeType returns the kind of value inside this struct.
  1230  //
  1231  // This will always be Reply for this struct.
  1232  func (v *TestService_Call_Result) EnvelopeType() wire.EnvelopeType {
  1233  	return wire.Reply
  1234  }