github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/chat/flip/prot.go (about)

     1  // Auto-generated by avdl-compiler v1.3.29 (https://github.com/keybase/node-avdl-compiler)
     2  //   Input file: prot.avdl
     3  
     4  package flip
     5  
     6  import (
     7  	"errors"
     8  	chat1 "github.com/keybase/client/go/protocol/chat1"
     9  	gregor1 "github.com/keybase/client/go/protocol/gregor1"
    10  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    11  )
    12  
    13  type Time int64
    14  
    15  func (o Time) DeepCopy() Time {
    16  	return o
    17  }
    18  
    19  type Start struct {
    20  	StartTime                    Time           `codec:"startTime" json:"startTime"`
    21  	CommitmentWindowMsec         int64          `codec:"commitmentWindowMsec" json:"commitmentWindowMsec"`
    22  	RevealWindowMsec             int64          `codec:"revealWindowMsec" json:"revealWindowMsec"`
    23  	SlackMsec                    int64          `codec:"slackMsec" json:"slackMsec"`
    24  	CommitmentCompleteWindowMsec int64          `codec:"commitmentCompleteWindowMsec" json:"commitmentCompleteWindowMsec"`
    25  	Params                       FlipParameters `codec:"params" json:"params"`
    26  }
    27  
    28  func (o Start) DeepCopy() Start {
    29  	return Start{
    30  		StartTime:                    o.StartTime.DeepCopy(),
    31  		CommitmentWindowMsec:         o.CommitmentWindowMsec,
    32  		RevealWindowMsec:             o.RevealWindowMsec,
    33  		SlackMsec:                    o.SlackMsec,
    34  		CommitmentCompleteWindowMsec: o.CommitmentCompleteWindowMsec,
    35  		Params:                       o.Params.DeepCopy(),
    36  	}
    37  }
    38  
    39  type UserDevice struct {
    40  	D gregor1.DeviceID `codec:"d" json:"d"`
    41  	U gregor1.UID      `codec:"u" json:"u"`
    42  }
    43  
    44  func (o UserDevice) DeepCopy() UserDevice {
    45  	return UserDevice{
    46  		D: o.D.DeepCopy(),
    47  		U: o.U.DeepCopy(),
    48  	}
    49  }
    50  
    51  type GameMetadata struct {
    52  	Initiator      UserDevice           `codec:"initiator" json:"initiator"`
    53  	ConversationID chat1.ConversationID `codec:"conversationID" json:"conversationID"`
    54  	GameID         chat1.FlipGameID     `codec:"gameID" json:"gameID"`
    55  }
    56  
    57  func (o GameMetadata) DeepCopy() GameMetadata {
    58  	return GameMetadata{
    59  		Initiator:      o.Initiator.DeepCopy(),
    60  		ConversationID: o.ConversationID.DeepCopy(),
    61  		GameID:         o.GameID.DeepCopy(),
    62  	}
    63  }
    64  
    65  type CommitmentComplete struct {
    66  	Players []UserDeviceCommitment `codec:"players" json:"players"`
    67  }
    68  
    69  func (o CommitmentComplete) DeepCopy() CommitmentComplete {
    70  	return CommitmentComplete{
    71  		Players: (func(x []UserDeviceCommitment) []UserDeviceCommitment {
    72  			if x == nil {
    73  				return nil
    74  			}
    75  			ret := make([]UserDeviceCommitment, len(x))
    76  			for i, v := range x {
    77  				vCopy := v.DeepCopy()
    78  				ret[i] = vCopy
    79  			}
    80  			return ret
    81  		})(o.Players),
    82  	}
    83  }
    84  
    85  type FlipType int
    86  
    87  const (
    88  	FlipType_BOOL    FlipType = 1
    89  	FlipType_INT     FlipType = 2
    90  	FlipType_BIG     FlipType = 3
    91  	FlipType_SHUFFLE FlipType = 4
    92  )
    93  
    94  func (o FlipType) DeepCopy() FlipType { return o }
    95  
    96  var FlipTypeMap = map[string]FlipType{
    97  	"BOOL":    1,
    98  	"INT":     2,
    99  	"BIG":     3,
   100  	"SHUFFLE": 4,
   101  }
   102  
   103  var FlipTypeRevMap = map[FlipType]string{
   104  	1: "BOOL",
   105  	2: "INT",
   106  	3: "BIG",
   107  	4: "SHUFFLE",
   108  }
   109  
   110  func (e FlipType) String() string {
   111  	if v, ok := FlipTypeRevMap[e]; ok {
   112  		return v
   113  	}
   114  	return ""
   115  }
   116  
   117  type FlipParameters struct {
   118  	T__       FlipType `codec:"t" json:"t"`
   119  	Int__     *int64   `codec:"int,omitempty" json:"int,omitempty"`
   120  	Big__     *[]byte  `codec:"big,omitempty" json:"big,omitempty"`
   121  	Shuffle__ *int64   `codec:"shuffle,omitempty" json:"shuffle,omitempty"`
   122  }
   123  
   124  func (o *FlipParameters) T() (ret FlipType, err error) {
   125  	switch o.T__ {
   126  	case FlipType_INT:
   127  		if o.Int__ == nil {
   128  			err = errors.New("unexpected nil value for Int__")
   129  			return ret, err
   130  		}
   131  	case FlipType_BIG:
   132  		if o.Big__ == nil {
   133  			err = errors.New("unexpected nil value for Big__")
   134  			return ret, err
   135  		}
   136  	case FlipType_SHUFFLE:
   137  		if o.Shuffle__ == nil {
   138  			err = errors.New("unexpected nil value for Shuffle__")
   139  			return ret, err
   140  		}
   141  	}
   142  	return o.T__, nil
   143  }
   144  
   145  func (o FlipParameters) Int() (res int64) {
   146  	if o.T__ != FlipType_INT {
   147  		panic("wrong case accessed")
   148  	}
   149  	if o.Int__ == nil {
   150  		return
   151  	}
   152  	return *o.Int__
   153  }
   154  
   155  func (o FlipParameters) Big() (res []byte) {
   156  	if o.T__ != FlipType_BIG {
   157  		panic("wrong case accessed")
   158  	}
   159  	if o.Big__ == nil {
   160  		return
   161  	}
   162  	return *o.Big__
   163  }
   164  
   165  func (o FlipParameters) Shuffle() (res int64) {
   166  	if o.T__ != FlipType_SHUFFLE {
   167  		panic("wrong case accessed")
   168  	}
   169  	if o.Shuffle__ == nil {
   170  		return
   171  	}
   172  	return *o.Shuffle__
   173  }
   174  
   175  func NewFlipParametersWithBool() FlipParameters {
   176  	return FlipParameters{
   177  		T__: FlipType_BOOL,
   178  	}
   179  }
   180  
   181  func NewFlipParametersWithInt(v int64) FlipParameters {
   182  	return FlipParameters{
   183  		T__:   FlipType_INT,
   184  		Int__: &v,
   185  	}
   186  }
   187  
   188  func NewFlipParametersWithBig(v []byte) FlipParameters {
   189  	return FlipParameters{
   190  		T__:   FlipType_BIG,
   191  		Big__: &v,
   192  	}
   193  }
   194  
   195  func NewFlipParametersWithShuffle(v int64) FlipParameters {
   196  	return FlipParameters{
   197  		T__:       FlipType_SHUFFLE,
   198  		Shuffle__: &v,
   199  	}
   200  }
   201  
   202  func (o FlipParameters) DeepCopy() FlipParameters {
   203  	return FlipParameters{
   204  		T__: o.T__.DeepCopy(),
   205  		Int__: (func(x *int64) *int64 {
   206  			if x == nil {
   207  				return nil
   208  			}
   209  			tmp := (*x)
   210  			return &tmp
   211  		})(o.Int__),
   212  		Big__: (func(x *[]byte) *[]byte {
   213  			if x == nil {
   214  				return nil
   215  			}
   216  			tmp := (func(x []byte) []byte {
   217  				if x == nil {
   218  					return nil
   219  				}
   220  				return append([]byte{}, x...)
   221  			})((*x))
   222  			return &tmp
   223  		})(o.Big__),
   224  		Shuffle__: (func(x *int64) *int64 {
   225  			if x == nil {
   226  				return nil
   227  			}
   228  			tmp := (*x)
   229  			return &tmp
   230  		})(o.Shuffle__),
   231  	}
   232  }
   233  
   234  type MessageType int
   235  
   236  const (
   237  	MessageType_START               MessageType = 1
   238  	MessageType_COMMITMENT          MessageType = 2
   239  	MessageType_COMMITMENT_COMPLETE MessageType = 3
   240  	MessageType_REVEAL              MessageType = 4
   241  	MessageType_END                 MessageType = 5
   242  )
   243  
   244  func (o MessageType) DeepCopy() MessageType { return o }
   245  
   246  var MessageTypeMap = map[string]MessageType{
   247  	"START":               1,
   248  	"COMMITMENT":          2,
   249  	"COMMITMENT_COMPLETE": 3,
   250  	"REVEAL":              4,
   251  	"END":                 5,
   252  }
   253  
   254  var MessageTypeRevMap = map[MessageType]string{
   255  	1: "START",
   256  	2: "COMMITMENT",
   257  	3: "COMMITMENT_COMPLETE",
   258  	4: "REVEAL",
   259  	5: "END",
   260  }
   261  
   262  func (e MessageType) String() string {
   263  	if v, ok := MessageTypeRevMap[e]; ok {
   264  		return v
   265  	}
   266  	return ""
   267  }
   268  
   269  type Stage int
   270  
   271  const (
   272  	Stage_ROUND1 Stage = 1
   273  	Stage_ROUND2 Stage = 2
   274  )
   275  
   276  func (o Stage) DeepCopy() Stage { return o }
   277  
   278  var StageMap = map[string]Stage{
   279  	"ROUND1": 1,
   280  	"ROUND2": 2,
   281  }
   282  
   283  var StageRevMap = map[Stage]string{
   284  	1: "ROUND1",
   285  	2: "ROUND2",
   286  }
   287  
   288  func (e Stage) String() string {
   289  	if v, ok := StageRevMap[e]; ok {
   290  		return v
   291  	}
   292  	return ""
   293  }
   294  
   295  type Secret [32]byte
   296  
   297  func (o Secret) DeepCopy() Secret {
   298  	var ret Secret
   299  	copy(ret[:], o[:])
   300  	return ret
   301  }
   302  
   303  type Commitment [32]byte
   304  
   305  func (o Commitment) DeepCopy() Commitment {
   306  	var ret Commitment
   307  	copy(ret[:], o[:])
   308  	return ret
   309  }
   310  
   311  type UserDeviceCommitment struct {
   312  	Ud UserDevice `codec:"ud" json:"ud"`
   313  	C  Commitment `codec:"c" json:"c"`
   314  }
   315  
   316  func (o UserDeviceCommitment) DeepCopy() UserDeviceCommitment {
   317  	return UserDeviceCommitment{
   318  		Ud: o.Ud.DeepCopy(),
   319  		C:  o.C.DeepCopy(),
   320  	}
   321  }
   322  
   323  type Hash [32]byte
   324  
   325  func (o Hash) DeepCopy() Hash {
   326  	var ret Hash
   327  	copy(ret[:], o[:])
   328  	return ret
   329  }
   330  
   331  type Reveal struct {
   332  	Secret Secret `codec:"secret" json:"secret"`
   333  	Cch    Hash   `codec:"cch" json:"cch"`
   334  }
   335  
   336  func (o Reveal) DeepCopy() Reveal {
   337  	return Reveal{
   338  		Secret: o.Secret.DeepCopy(),
   339  		Cch:    o.Cch.DeepCopy(),
   340  	}
   341  }
   342  
   343  type GameMessageBody struct {
   344  	T__                  MessageType         `codec:"t" json:"t"`
   345  	Start__              *Start              `codec:"start,omitempty" json:"start,omitempty"`
   346  	Commitment__         *Commitment         `codec:"commitment,omitempty" json:"commitment,omitempty"`
   347  	CommitmentComplete__ *CommitmentComplete `codec:"commitmentComplete,omitempty" json:"commitmentComplete,omitempty"`
   348  	Reveal__             *Reveal             `codec:"reveal,omitempty" json:"reveal,omitempty"`
   349  }
   350  
   351  func (o *GameMessageBody) T() (ret MessageType, err error) {
   352  	switch o.T__ {
   353  	case MessageType_START:
   354  		if o.Start__ == nil {
   355  			err = errors.New("unexpected nil value for Start__")
   356  			return ret, err
   357  		}
   358  	case MessageType_COMMITMENT:
   359  		if o.Commitment__ == nil {
   360  			err = errors.New("unexpected nil value for Commitment__")
   361  			return ret, err
   362  		}
   363  	case MessageType_COMMITMENT_COMPLETE:
   364  		if o.CommitmentComplete__ == nil {
   365  			err = errors.New("unexpected nil value for CommitmentComplete__")
   366  			return ret, err
   367  		}
   368  	case MessageType_REVEAL:
   369  		if o.Reveal__ == nil {
   370  			err = errors.New("unexpected nil value for Reveal__")
   371  			return ret, err
   372  		}
   373  	}
   374  	return o.T__, nil
   375  }
   376  
   377  func (o GameMessageBody) Start() (res Start) {
   378  	if o.T__ != MessageType_START {
   379  		panic("wrong case accessed")
   380  	}
   381  	if o.Start__ == nil {
   382  		return
   383  	}
   384  	return *o.Start__
   385  }
   386  
   387  func (o GameMessageBody) Commitment() (res Commitment) {
   388  	if o.T__ != MessageType_COMMITMENT {
   389  		panic("wrong case accessed")
   390  	}
   391  	if o.Commitment__ == nil {
   392  		return
   393  	}
   394  	return *o.Commitment__
   395  }
   396  
   397  func (o GameMessageBody) CommitmentComplete() (res CommitmentComplete) {
   398  	if o.T__ != MessageType_COMMITMENT_COMPLETE {
   399  		panic("wrong case accessed")
   400  	}
   401  	if o.CommitmentComplete__ == nil {
   402  		return
   403  	}
   404  	return *o.CommitmentComplete__
   405  }
   406  
   407  func (o GameMessageBody) Reveal() (res Reveal) {
   408  	if o.T__ != MessageType_REVEAL {
   409  		panic("wrong case accessed")
   410  	}
   411  	if o.Reveal__ == nil {
   412  		return
   413  	}
   414  	return *o.Reveal__
   415  }
   416  
   417  func NewGameMessageBodyWithStart(v Start) GameMessageBody {
   418  	return GameMessageBody{
   419  		T__:     MessageType_START,
   420  		Start__: &v,
   421  	}
   422  }
   423  
   424  func NewGameMessageBodyWithCommitment(v Commitment) GameMessageBody {
   425  	return GameMessageBody{
   426  		T__:          MessageType_COMMITMENT,
   427  		Commitment__: &v,
   428  	}
   429  }
   430  
   431  func NewGameMessageBodyWithCommitmentComplete(v CommitmentComplete) GameMessageBody {
   432  	return GameMessageBody{
   433  		T__:                  MessageType_COMMITMENT_COMPLETE,
   434  		CommitmentComplete__: &v,
   435  	}
   436  }
   437  
   438  func NewGameMessageBodyWithReveal(v Reveal) GameMessageBody {
   439  	return GameMessageBody{
   440  		T__:      MessageType_REVEAL,
   441  		Reveal__: &v,
   442  	}
   443  }
   444  
   445  func NewGameMessageBodyWithEnd() GameMessageBody {
   446  	return GameMessageBody{
   447  		T__: MessageType_END,
   448  	}
   449  }
   450  
   451  func (o GameMessageBody) DeepCopy() GameMessageBody {
   452  	return GameMessageBody{
   453  		T__: o.T__.DeepCopy(),
   454  		Start__: (func(x *Start) *Start {
   455  			if x == nil {
   456  				return nil
   457  			}
   458  			tmp := (*x).DeepCopy()
   459  			return &tmp
   460  		})(o.Start__),
   461  		Commitment__: (func(x *Commitment) *Commitment {
   462  			if x == nil {
   463  				return nil
   464  			}
   465  			tmp := (*x).DeepCopy()
   466  			return &tmp
   467  		})(o.Commitment__),
   468  		CommitmentComplete__: (func(x *CommitmentComplete) *CommitmentComplete {
   469  			if x == nil {
   470  				return nil
   471  			}
   472  			tmp := (*x).DeepCopy()
   473  			return &tmp
   474  		})(o.CommitmentComplete__),
   475  		Reveal__: (func(x *Reveal) *Reveal {
   476  			if x == nil {
   477  				return nil
   478  			}
   479  			tmp := (*x).DeepCopy()
   480  			return &tmp
   481  		})(o.Reveal__),
   482  	}
   483  }
   484  
   485  type Version int
   486  
   487  const (
   488  	Version_V1 Version = 1
   489  )
   490  
   491  func (o Version) DeepCopy() Version { return o }
   492  
   493  var VersionMap = map[string]Version{
   494  	"V1": 1,
   495  }
   496  
   497  var VersionRevMap = map[Version]string{
   498  	1: "V1",
   499  }
   500  
   501  func (e Version) String() string {
   502  	if v, ok := VersionRevMap[e]; ok {
   503  		return v
   504  	}
   505  	return ""
   506  }
   507  
   508  type GameMessage struct {
   509  	V__  Version        `codec:"v" json:"v"`
   510  	V1__ *GameMessageV1 `codec:"v1,omitempty" json:"v1,omitempty"`
   511  }
   512  
   513  func (o *GameMessage) V() (ret Version, err error) {
   514  	switch o.V__ {
   515  	case Version_V1:
   516  		if o.V1__ == nil {
   517  			err = errors.New("unexpected nil value for V1__")
   518  			return ret, err
   519  		}
   520  	}
   521  	return o.V__, nil
   522  }
   523  
   524  func (o GameMessage) V1() (res GameMessageV1) {
   525  	if o.V__ != Version_V1 {
   526  		panic("wrong case accessed")
   527  	}
   528  	if o.V1__ == nil {
   529  		return
   530  	}
   531  	return *o.V1__
   532  }
   533  
   534  func NewGameMessageWithV1(v GameMessageV1) GameMessage {
   535  	return GameMessage{
   536  		V__:  Version_V1,
   537  		V1__: &v,
   538  	}
   539  }
   540  
   541  func NewGameMessageDefault(v Version) GameMessage {
   542  	return GameMessage{
   543  		V__: v,
   544  	}
   545  }
   546  
   547  func (o GameMessage) DeepCopy() GameMessage {
   548  	return GameMessage{
   549  		V__: o.V__.DeepCopy(),
   550  		V1__: (func(x *GameMessageV1) *GameMessageV1 {
   551  			if x == nil {
   552  				return nil
   553  			}
   554  			tmp := (*x).DeepCopy()
   555  			return &tmp
   556  		})(o.V1__),
   557  	}
   558  }
   559  
   560  type GameMessageV1 struct {
   561  	Md   GameMetadata    `codec:"md" json:"md"`
   562  	Body GameMessageBody `codec:"body" json:"body"`
   563  }
   564  
   565  func (o GameMessageV1) DeepCopy() GameMessageV1 {
   566  	return GameMessageV1{
   567  		Md:   o.Md.DeepCopy(),
   568  		Body: o.Body.DeepCopy(),
   569  	}
   570  }
   571  
   572  type FlipInterface interface {
   573  }
   574  
   575  func FlipProtocol(i FlipInterface) rpc.Protocol {
   576  	return rpc.Protocol{
   577  		Name:    "flip.flip",
   578  		Methods: map[string]rpc.ServeHandlerDescription{},
   579  	}
   580  }
   581  
   582  type FlipClient struct {
   583  	Cli rpc.GenericClient
   584  }