github.com/stellar/go-xdr@v0.0.0-20231122183749-b53fb00bcac2/xdr3/main.go (about)

     1  package xdr
     2  
     3  // Enum indicates this implementing type should be serialized/deserialized
     4  // as an XDR Enum.  Implement ValidEnum to specify what values are valid for
     5  // this enum.
     6  type Enum interface {
     7  	ValidEnum(int32) bool
     8  }
     9  
    10  // Sized types are types that have an explicit maximum size.  By default, the
    11  // variable length XDR types (VarArray, VarOpaque and String) have a maximum
    12  // byte size of a 2^32-1, but an implementor of this type may reduce that
    13  // maximum to an appropriate value for the XDR schema in use.
    14  type Sized interface {
    15  	XDRMaxSize() int
    16  }
    17  
    18  // Union indicates the implementing type should be serialized/deserialized as
    19  // an XDR Union.  The implementer must provide public fields, one for the
    20  // union's disciminant, whose name must be returned by ArmForSwitch(), and
    21  // one per potential value of the union, which must be a pointer.  For example:
    22  //
    23  //	type Result struct {
    24  //	  Type ResultType  // this is the union's disciminant, may be 0 to indicate success, 1 to indicate error
    25  //	  Msg  *string // this field will be populated when Type == 1
    26  //	}
    27  type Union interface {
    28  	ArmForSwitch(int32) (string, bool)
    29  	SwitchFieldName() string
    30  }