github.com/stafiprotocol/go-substrate-rpc-client@v1.4.7/types/option_bytes.go (about)

     1  // Go Substrate RPC Client (GSRPC) provides APIs and types around Polkadot and any Substrate-based chain RPC calls
     2  //
     3  // Copyright 2020 Stafi Protocol
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  package types
    18  
    19  import "github.com/stafiprotocol/go-substrate-rpc-client/pkg/scale"
    20  
    21  // OptionBytes is a structure that can store a Bytes or a missing value
    22  type OptionBytes struct {
    23  	option
    24  	value Bytes
    25  }
    26  
    27  // NewOptionBytes creates an OptionBytes with a value
    28  func NewOptionBytes(value Bytes) OptionBytes {
    29  	return OptionBytes{option{true}, value}
    30  }
    31  
    32  // NewOptionBytesEmpty creates an OptionBytes without a value
    33  func NewOptionBytesEmpty() OptionBytes {
    34  	return OptionBytes{option: option{false}}
    35  }
    36  
    37  func (o OptionBytes) Encode(encoder scale.Encoder) error {
    38  	return encoder.EncodeOption(o.hasValue, o.value)
    39  }
    40  
    41  func (o *OptionBytes) Decode(decoder scale.Decoder) error {
    42  	return decoder.DecodeOption(&o.hasValue, &o.value)
    43  }
    44  
    45  // SetSome sets a value
    46  func (o *OptionBytes) SetSome(value Bytes) {
    47  	o.hasValue = true
    48  	o.value = value
    49  }
    50  
    51  // SetNone removes a value and marks it as missing
    52  func (o *OptionBytes) SetNone() {
    53  	o.hasValue = false
    54  	o.value = Bytes{}
    55  }
    56  
    57  // Unwrap returns a flag that indicates whether a value is present and the stored value
    58  func (o OptionBytes) Unwrap() (ok bool, value Bytes) {
    59  	return o.hasValue, o.value
    60  }
    61  
    62  // OptionBytes8 is a structure that can store a Bytes8 or a missing value
    63  type OptionBytes8 struct {
    64  	option
    65  	value Bytes8
    66  }
    67  
    68  // NewOptionBytes8 creates an OptionBytes8 with a value
    69  func NewOptionBytes8(value Bytes8) OptionBytes8 {
    70  	return OptionBytes8{option{true}, value}
    71  }
    72  
    73  // NewOptionBytes8Empty creates an OptionBytes8 without a value
    74  func NewOptionBytes8Empty() OptionBytes8 {
    75  	return OptionBytes8{option: option{false}}
    76  }
    77  
    78  func (o OptionBytes8) Encode(encoder scale.Encoder) error {
    79  	return encoder.EncodeOption(o.hasValue, o.value)
    80  }
    81  
    82  func (o *OptionBytes8) Decode(decoder scale.Decoder) error {
    83  	return decoder.DecodeOption(&o.hasValue, &o.value)
    84  }
    85  
    86  // SetSome sets a value
    87  func (o *OptionBytes8) SetSome(value Bytes8) {
    88  	o.hasValue = true
    89  	o.value = value
    90  }
    91  
    92  // SetNone removes a value and marks it as missing
    93  func (o *OptionBytes8) SetNone() {
    94  	o.hasValue = false
    95  	o.value = Bytes8{}
    96  }
    97  
    98  // Unwrap returns a flag that indicates whether a value is present and the stored value
    99  func (o OptionBytes8) Unwrap() (ok bool, value Bytes8) {
   100  	return o.hasValue, o.value
   101  }
   102  
   103  // OptionBytes16 is a structure that can store a Bytes16 or a missing value
   104  type OptionBytes16 struct {
   105  	option
   106  	value Bytes16
   107  }
   108  
   109  // NewOptionBytes16 creates an OptionBytes16 with a value
   110  func NewOptionBytes16(value Bytes16) OptionBytes16 {
   111  	return OptionBytes16{option{true}, value}
   112  }
   113  
   114  // NewOptionBytes16Empty creates an OptionBytes16 without a value
   115  func NewOptionBytes16Empty() OptionBytes16 {
   116  	return OptionBytes16{option: option{false}}
   117  }
   118  
   119  func (o OptionBytes16) Encode(encoder scale.Encoder) error {
   120  	return encoder.EncodeOption(o.hasValue, o.value)
   121  }
   122  
   123  func (o *OptionBytes16) Decode(decoder scale.Decoder) error {
   124  	return decoder.DecodeOption(&o.hasValue, &o.value)
   125  }
   126  
   127  // SetSome sets a value
   128  func (o *OptionBytes16) SetSome(value Bytes16) {
   129  	o.hasValue = true
   130  	o.value = value
   131  }
   132  
   133  // SetNone removes a value and marks it as missing
   134  func (o *OptionBytes16) SetNone() {
   135  	o.hasValue = false
   136  	o.value = Bytes16{}
   137  }
   138  
   139  // Unwrap returns a flag that indicates whether a value is present and the stored value
   140  func (o OptionBytes16) Unwrap() (ok bool, value Bytes16) {
   141  	return o.hasValue, o.value
   142  }
   143  
   144  // OptionBytes32 is a structure that can store a Bytes32 or a missing value
   145  type OptionBytes32 struct {
   146  	option
   147  	value Bytes32
   148  }
   149  
   150  // NewOptionBytes32 creates an OptionBytes32 with a value
   151  func NewOptionBytes32(value Bytes32) OptionBytes32 {
   152  	return OptionBytes32{option{true}, value}
   153  }
   154  
   155  // NewOptionBytes32Empty creates an OptionBytes32 without a value
   156  func NewOptionBytes32Empty() OptionBytes32 {
   157  	return OptionBytes32{option: option{false}}
   158  }
   159  
   160  func (o OptionBytes32) Encode(encoder scale.Encoder) error {
   161  	return encoder.EncodeOption(o.hasValue, o.value)
   162  }
   163  
   164  func (o *OptionBytes32) Decode(decoder scale.Decoder) error {
   165  	return decoder.DecodeOption(&o.hasValue, &o.value)
   166  }
   167  
   168  // SetSome sets a value
   169  func (o *OptionBytes32) SetSome(value Bytes32) {
   170  	o.hasValue = true
   171  	o.value = value
   172  }
   173  
   174  // SetNone removes a value and marks it as missing
   175  func (o *OptionBytes32) SetNone() {
   176  	o.hasValue = false
   177  	o.value = Bytes32{}
   178  }
   179  
   180  // Unwrap returns a flag that indicates whether a value is present and the stored value
   181  func (o OptionBytes32) Unwrap() (ok bool, value Bytes32) {
   182  	return o.hasValue, o.value
   183  }
   184  
   185  // OptionBytes64 is a structure that can store a Bytes64 or a missing value
   186  type OptionBytes64 struct {
   187  	option
   188  	value Bytes64
   189  }
   190  
   191  // NewOptionBytes64 creates an OptionBytes64 with a value
   192  func NewOptionBytes64(value Bytes64) OptionBytes64 {
   193  	return OptionBytes64{option{true}, value}
   194  }
   195  
   196  // NewOptionBytes64Empty creates an OptionBytes64 without a value
   197  func NewOptionBytes64Empty() OptionBytes64 {
   198  	return OptionBytes64{option: option{false}}
   199  }
   200  
   201  func (o OptionBytes64) Encode(encoder scale.Encoder) error {
   202  	return encoder.EncodeOption(o.hasValue, o.value)
   203  }
   204  
   205  func (o *OptionBytes64) Decode(decoder scale.Decoder) error {
   206  	return decoder.DecodeOption(&o.hasValue, &o.value)
   207  }
   208  
   209  // SetSome sets a value
   210  func (o *OptionBytes64) SetSome(value Bytes64) {
   211  	o.hasValue = true
   212  	o.value = value
   213  }
   214  
   215  // SetNone removes a value and marks it as missing
   216  func (o *OptionBytes64) SetNone() {
   217  	o.hasValue = false
   218  	o.value = Bytes64{}
   219  }
   220  
   221  // Unwrap returns a flag that indicates whether a value is present and the stored value
   222  func (o OptionBytes64) Unwrap() (ok bool, value Bytes64) {
   223  	return o.hasValue, o.value
   224  }
   225  
   226  // OptionBytes128 is a structure that can store a Bytes128 or a missing value
   227  type OptionBytes128 struct {
   228  	option
   229  	value Bytes128
   230  }
   231  
   232  // NewOptionBytes128 creates an OptionBytes128 with a value
   233  func NewOptionBytes128(value Bytes128) OptionBytes128 {
   234  	return OptionBytes128{option{true}, value}
   235  }
   236  
   237  // NewOptionBytes128Empty creates an OptionBytes128 without a value
   238  func NewOptionBytes128Empty() OptionBytes128 {
   239  	return OptionBytes128{option: option{false}}
   240  }
   241  
   242  func (o OptionBytes128) Encode(encoder scale.Encoder) error {
   243  	return encoder.EncodeOption(o.hasValue, o.value)
   244  }
   245  
   246  func (o *OptionBytes128) Decode(decoder scale.Decoder) error {
   247  	return decoder.DecodeOption(&o.hasValue, &o.value)
   248  }
   249  
   250  // SetSome sets a value
   251  func (o *OptionBytes128) SetSome(value Bytes128) {
   252  	o.hasValue = true
   253  	o.value = value
   254  }
   255  
   256  // SetNone removes a value and marks it as missing
   257  func (o *OptionBytes128) SetNone() {
   258  	o.hasValue = false
   259  	o.value = Bytes128{}
   260  }
   261  
   262  // Unwrap returns a flag that indicates whether a value is present and the stored value
   263  func (o OptionBytes128) Unwrap() (ok bool, value Bytes128) {
   264  	return o.hasValue, o.value
   265  }
   266  
   267  // OptionBytes256 is a structure that can store a Bytes256 or a missing value
   268  type OptionBytes256 struct {
   269  	option
   270  	value Bytes256
   271  }
   272  
   273  // NewOptionBytes256 creates an OptionBytes256 with a value
   274  func NewOptionBytes256(value Bytes256) OptionBytes256 {
   275  	return OptionBytes256{option{true}, value}
   276  }
   277  
   278  // NewOptionBytes256Empty creates an OptionBytes256 without a value
   279  func NewOptionBytes256Empty() OptionBytes256 {
   280  	return OptionBytes256{option: option{false}}
   281  }
   282  
   283  func (o OptionBytes256) Encode(encoder scale.Encoder) error {
   284  	return encoder.EncodeOption(o.hasValue, o.value)
   285  }
   286  
   287  func (o *OptionBytes256) Decode(decoder scale.Decoder) error {
   288  	return decoder.DecodeOption(&o.hasValue, &o.value)
   289  }
   290  
   291  // SetSome sets a value
   292  func (o *OptionBytes256) SetSome(value Bytes256) {
   293  	o.hasValue = true
   294  	o.value = value
   295  }
   296  
   297  // SetNone removes a value and marks it as missing
   298  func (o *OptionBytes256) SetNone() {
   299  	o.hasValue = false
   300  	o.value = Bytes256{}
   301  }
   302  
   303  // Unwrap returns a flag that indicates whether a value is present and the stored value
   304  func (o OptionBytes256) Unwrap() (ok bool, value Bytes256) {
   305  	return o.hasValue, o.value
   306  }
   307  
   308  // OptionBytes512 is a structure that can store a Bytes512 or a missing value
   309  type OptionBytes512 struct {
   310  	option
   311  	value Bytes512
   312  }
   313  
   314  // NewOptionBytes512 creates an OptionBytes512 with a value
   315  func NewOptionBytes512(value Bytes512) OptionBytes512 {
   316  	return OptionBytes512{option{true}, value}
   317  }
   318  
   319  // NewOptionBytes512Empty creates an OptionBytes512 without a value
   320  func NewOptionBytes512Empty() OptionBytes512 {
   321  	return OptionBytes512{option: option{false}}
   322  }
   323  
   324  func (o OptionBytes512) Encode(encoder scale.Encoder) error {
   325  	return encoder.EncodeOption(o.hasValue, o.value)
   326  }
   327  
   328  func (o *OptionBytes512) Decode(decoder scale.Decoder) error {
   329  	return decoder.DecodeOption(&o.hasValue, &o.value)
   330  }
   331  
   332  // SetSome sets a value
   333  func (o *OptionBytes512) SetSome(value Bytes512) {
   334  	o.hasValue = true
   335  	o.value = value
   336  }
   337  
   338  // SetNone removes a value and marks it as missing
   339  func (o *OptionBytes512) SetNone() {
   340  	o.hasValue = false
   341  	o.value = Bytes512{}
   342  }
   343  
   344  // Unwrap returns a flag that indicates whether a value is present and the stored value
   345  func (o OptionBytes512) Unwrap() (ok bool, value Bytes512) {
   346  	return o.hasValue, o.value
   347  }
   348  
   349  // OptionBytes1024 is a structure that can store a Bytes1024 or a missing value
   350  type OptionBytes1024 struct {
   351  	option
   352  	value Bytes1024
   353  }
   354  
   355  // NewOptionBytes1024 creates an OptionBytes1024 with a value
   356  func NewOptionBytes1024(value Bytes1024) OptionBytes1024 {
   357  	return OptionBytes1024{option{true}, value}
   358  }
   359  
   360  // NewOptionBytes1024Empty creates an OptionBytes1024 without a value
   361  func NewOptionBytes1024Empty() OptionBytes1024 {
   362  	return OptionBytes1024{option: option{false}}
   363  }
   364  
   365  func (o OptionBytes1024) Encode(encoder scale.Encoder) error {
   366  	return encoder.EncodeOption(o.hasValue, o.value)
   367  }
   368  
   369  func (o *OptionBytes1024) Decode(decoder scale.Decoder) error {
   370  	return decoder.DecodeOption(&o.hasValue, &o.value)
   371  }
   372  
   373  // SetSome sets a value
   374  func (o *OptionBytes1024) SetSome(value Bytes1024) {
   375  	o.hasValue = true
   376  	o.value = value
   377  }
   378  
   379  // SetNone removes a value and marks it as missing
   380  func (o *OptionBytes1024) SetNone() {
   381  	o.hasValue = false
   382  	o.value = Bytes1024{}
   383  }
   384  
   385  // Unwrap returns a flag that indicates whether a value is present and the stored value
   386  func (o OptionBytes1024) Unwrap() (ok bool, value Bytes1024) {
   387  	return o.hasValue, o.value
   388  }
   389  
   390  // OptionBytes2048 is a structure that can store a Bytes2048 or a missing value
   391  type OptionBytes2048 struct {
   392  	option
   393  	value Bytes2048
   394  }
   395  
   396  // NewOptionBytes2048 creates an OptionBytes2048 with a value
   397  func NewOptionBytes2048(value Bytes2048) OptionBytes2048 {
   398  	return OptionBytes2048{option{true}, value}
   399  }
   400  
   401  // NewOptionBytes2048Empty creates an OptionBytes2048 without a value
   402  func NewOptionBytes2048Empty() OptionBytes2048 {
   403  	return OptionBytes2048{option: option{false}}
   404  }
   405  
   406  func (o OptionBytes2048) Encode(encoder scale.Encoder) error {
   407  	return encoder.EncodeOption(o.hasValue, o.value)
   408  }
   409  
   410  func (o *OptionBytes2048) Decode(decoder scale.Decoder) error {
   411  	return decoder.DecodeOption(&o.hasValue, &o.value)
   412  }
   413  
   414  // SetSome sets a value
   415  func (o *OptionBytes2048) SetSome(value Bytes2048) {
   416  	o.hasValue = true
   417  	o.value = value
   418  }
   419  
   420  // SetNone removes a value and marks it as missing
   421  func (o *OptionBytes2048) SetNone() {
   422  	o.hasValue = false
   423  	o.value = Bytes2048{}
   424  }
   425  
   426  // Unwrap returns a flag that indicates whether a value is present and the stored value
   427  func (o OptionBytes2048) Unwrap() (ok bool, value Bytes2048) {
   428  	return o.hasValue, o.value
   429  }