github.com/aeternity/aepp-sdk-go@v1.0.3-0.20190606142815-1c0ffdc21fd9/generated/models/protocol.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  package models
     4  
     5  // This file was generated by the swagger tool.
     6  // Editing this file might prove futile when you re-run the swagger generate command
     7  
     8  import (
     9  	strfmt "github.com/go-openapi/strfmt"
    10  
    11  	"github.com/go-openapi/errors"
    12  	"github.com/go-openapi/swag"
    13  )
    14  
    15  // Protocol protocol
    16  // swagger:model Protocol
    17  type Protocol struct {
    18  
    19  	// effective at height
    20  	// Required: true
    21  	EffectiveAtHeight Uint64 `json:"effective_at_height"`
    22  
    23  	// version
    24  	// Required: true
    25  	Version Uint32 `json:"version"`
    26  }
    27  
    28  // Validate validates this protocol
    29  func (m *Protocol) Validate(formats strfmt.Registry) error {
    30  	var res []error
    31  
    32  	if err := m.validateEffectiveAtHeight(formats); err != nil {
    33  		res = append(res, err)
    34  	}
    35  
    36  	if err := m.validateVersion(formats); err != nil {
    37  		res = append(res, err)
    38  	}
    39  
    40  	if len(res) > 0 {
    41  		return errors.CompositeValidationError(res...)
    42  	}
    43  	return nil
    44  }
    45  
    46  func (m *Protocol) validateEffectiveAtHeight(formats strfmt.Registry) error {
    47  
    48  	if err := m.EffectiveAtHeight.Validate(formats); err != nil {
    49  		if ve, ok := err.(*errors.Validation); ok {
    50  			return ve.ValidateName("effective_at_height")
    51  		}
    52  		return err
    53  	}
    54  
    55  	return nil
    56  }
    57  
    58  func (m *Protocol) validateVersion(formats strfmt.Registry) error {
    59  
    60  	if err := m.Version.Validate(formats); err != nil {
    61  		if ve, ok := err.(*errors.Validation); ok {
    62  			return ve.ValidateName("version")
    63  		}
    64  		return err
    65  	}
    66  
    67  	return nil
    68  }
    69  
    70  // MarshalBinary interface implementation
    71  func (m *Protocol) MarshalBinary() ([]byte, error) {
    72  	if m == nil {
    73  		return nil, nil
    74  	}
    75  	return swag.WriteJSON(m)
    76  }
    77  
    78  // UnmarshalBinary interface implementation
    79  func (m *Protocol) UnmarshalBinary(b []byte) error {
    80  	var res Protocol
    81  	if err := swag.ReadJSON(b, &res); err != nil {
    82  		return err
    83  	}
    84  	*m = res
    85  	return nil
    86  }