github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/proto/protowire/README.md (about)

     1  <!-- Code generated by gomarkdoc. DO NOT EDIT -->
     2  
     3  # protowire
     4  
     5  ```go
     6  import "github.com/cloudwego/dynamicgo/proto/protowire"
     7  ```
     8  
     9  ## Index
    10  
    11  - [protowire](#protowire)
    12    - [Index](#index)
    13    - [func AppendFixed32](#func-appendfixed32)
    14    - [func AppendFixed64](#func-appendfixed64)
    15    - [func AppendVarint](#func-appendvarint)
    16    - [func ConsumeBytes](#func-consumebytes)
    17    - [func ConsumeFixed32](#func-consumefixed32)
    18    - [func ConsumeFixed64](#func-consumefixed64)
    19    - [func ConsumeVarint](#func-consumevarint)
    20    - [func DecodeZigZag](#func-decodezigzag)
    21    - [func EncodeZigZag](#func-encodezigzag)
    22    - [func SizeFixed32](#func-sizefixed32)
    23    - [func SizeFixed64](#func-sizefixed64)
    24    - [func SizeVarint](#func-sizevarint)
    25    - [type BinaryDecoder](#type-binarydecoder)
    26      - [func (BinaryDecoder) DecodeBool](#func-binarydecoder-decodebool)
    27      - [func (BinaryDecoder) DecodeByte](#func-binarydecoder-decodebyte)
    28      - [func (BinaryDecoder) DecodeBytes](#func-binarydecoder-decodebytes)
    29      - [func (BinaryDecoder) DecodeDouble](#func-binarydecoder-decodedouble)
    30      - [func (BinaryDecoder) DecodeFixed32](#func-binarydecoder-decodefixed32)
    31      - [func (BinaryDecoder) DecodeFixed64](#func-binarydecoder-decodefixed64)
    32      - [func (BinaryDecoder) DecodeFloat32](#func-binarydecoder-decodefloat32)
    33      - [func (BinaryDecoder) DecodeInt32](#func-binarydecoder-decodeint32)
    34      - [func (BinaryDecoder) DecodeInt64](#func-binarydecoder-decodeint64)
    35      - [func (BinaryDecoder) DecodeSfixed32](#func-binarydecoder-decodesfixed32)
    36      - [func (BinaryDecoder) DecodeSfixed64](#func-binarydecoder-decodesfixed64)
    37      - [func (BinaryDecoder) DecodeSint32](#func-binarydecoder-decodesint32)
    38      - [func (BinaryDecoder) DecodeSint64](#func-binarydecoder-decodesint64)
    39      - [func (BinaryDecoder) DecodeString](#func-binarydecoder-decodestring)
    40      - [func (BinaryDecoder) DecodeUint32](#func-binarydecoder-decodeuint32)
    41      - [func (BinaryDecoder) DecodeUint64](#func-binarydecoder-decodeuint64)
    42    - [type BinaryEncoder](#type-binaryencoder)
    43      - [func (BinaryEncoder) EncodeBool](#func-binaryencoder-encodebool)
    44      - [func (BinaryEncoder) EncodeByte](#func-binaryencoder-encodebyte)
    45      - [func (BinaryEncoder) EncodeBytes](#func-binaryencoder-encodebytes)
    46      - [func (BinaryEncoder) EncodeDouble](#func-binaryencoder-encodedouble)
    47      - [func (BinaryEncoder) EncodeEnum](#func-binaryencoder-encodeenum)
    48      - [func (BinaryEncoder) EncodeFixed32](#func-binaryencoder-encodefixed32)
    49      - [func (BinaryEncoder) EncodeFixed64](#func-binaryencoder-encodefixed64)
    50      - [func (BinaryEncoder) EncodeFloat32](#func-binaryencoder-encodefloat32)
    51      - [func (BinaryEncoder) EncodeInt32](#func-binaryencoder-encodeint32)
    52      - [func (BinaryEncoder) EncodeInt64](#func-binaryencoder-encodeint64)
    53      - [func (BinaryEncoder) EncodeSfixed32](#func-binaryencoder-encodesfixed32)
    54      - [func (BinaryEncoder) EncodeSfixed64](#func-binaryencoder-encodesfixed64)
    55      - [func (BinaryEncoder) EncodeSint32](#func-binaryencoder-encodesint32)
    56      - [func (BinaryEncoder) EncodeSint64](#func-binaryencoder-encodesint64)
    57      - [func (BinaryEncoder) EncodeString](#func-binaryencoder-encodestring)
    58      - [func (BinaryEncoder) EncodeUint32](#func-binaryencoder-encodeuint32)
    59      - [func (BinaryEncoder) EncodeUint64](#func-binaryencoder-encodeuint64)
    60  
    61  
    62  <a name="AppendFixed32"></a>
    63  ## func [AppendFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L93>)
    64  
    65  ```go
    66  func AppendFixed32(b []byte, v uint32) []byte
    67  ```
    68  
    69  AppendFixed32 appends v to b as a little-endian uint32.
    70  
    71  <a name="AppendFixed64"></a>
    72  ## func [AppendFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L102>)
    73  
    74  ```go
    75  func AppendFixed64(b []byte, v uint64) []byte
    76  ```
    77  
    78  AppendFixed64 appends v to b as a little-endian uint64.
    79  
    80  <a name="AppendVarint"></a>
    81  ## func [AppendVarint](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L12>)
    82  
    83  ```go
    84  func AppendVarint(b []byte, v uint64) []byte
    85  ```
    86  
    87  VarintEncode encodes a uint64 value as a varint-encoded byte slice. AppendVarint appends v to b as a varint-encoded uint64.
    88  
    89  <a name="ConsumeBytes"></a>
    90  ## func [ConsumeBytes](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L145>)
    91  
    92  ```go
    93  func ConsumeBytes(b []byte) (v []byte, n int, all int)
    94  ```
    95  
    96  ConsumeBytes parses b as a length-prefixed bytes value, reporting its length. This returns a negative length upon an error (see ParseError).
    97  
    98  <a name="ConsumeFixed32"></a>
    99  ## func [ConsumeFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L125>)
   100  
   101  ```go
   102  func ConsumeFixed32(b []byte) (v uint32, n int)
   103  ```
   104  
   105  ConsumeFixed32 parses b as a little-endian uint32, reporting its length. This returns a negative length upon an error (see ParseError).
   106  
   107  <a name="ConsumeFixed64"></a>
   108  ## func [ConsumeFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L135>)
   109  
   110  ```go
   111  func ConsumeFixed64(b []byte) (v uint64, n int)
   112  ```
   113  
   114  ConsumeFixed64 parses b as a little-endian uint64, reporting its length. This returns a negative length upon an error (see ParseError).
   115  
   116  <a name="ConsumeVarint"></a>
   117  ## func [ConsumeVarint](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L21>)
   118  
   119  ```go
   120  func ConsumeVarint(b []byte) (v uint64, n int)
   121  ```
   122  
   123  ConsumeVarint parses b as a varint-encoded uint64, reporting its length. This returns a negative length upon an error (see ParseError).
   124  
   125  <a name="DecodeZigZag"></a>
   126  ## func [DecodeZigZag](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L160>)
   127  
   128  ```go
   129  func DecodeZigZag(x uint64) int64
   130  ```
   131  
   132  DecodeZigZag decodes a zig-zag-encoded uint64 as an int64.
   133  
   134  ```
   135  Input:  {…,  5,  3,  1,  0,  2,  4,  6, …}
   136  Output: {…, -3, -2, -1,  0, +1, +2, +3, …}
   137  ```
   138  
   139  <a name="EncodeZigZag"></a>
   140  ## func [EncodeZigZag](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L118>)
   141  
   142  ```go
   143  func EncodeZigZag(v int64) uint64
   144  ```
   145  
   146  EncodeZigZag encodes an int64 as a zig-zag-encoded uint64.
   147  
   148  ```
   149  Input:  {…, -3, -2, -1,  0, +1, +2, +3, …}
   150  Output: {…,  5,  3,  1,  0,  2,  4,  6, …}
   151  ```
   152  
   153  <a name="SizeFixed32"></a>
   154  ## func [SizeFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L131>)
   155  
   156  ```go
   157  func SizeFixed32() int
   158  ```
   159  
   160  SizeFixed32 returns the encoded size of a fixed32; which is always 4.
   161  
   162  <a name="SizeFixed64"></a>
   163  ## func [SizeFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L136>)
   164  
   165  ```go
   166  func SizeFixed64() int
   167  ```
   168  
   169  SizeFixed64 returns the encoded size of a fixed64; which is always 8.
   170  
   171  <a name="SizeVarint"></a>
   172  ## func [SizeVarint](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L124>)
   173  
   174  ```go
   175  func SizeVarint(v uint64) int
   176  ```
   177  
   178  SizeVarint returns the encoded size of a varint. The size is guaranteed to be within 1 and 10, inclusive.
   179  
   180  <a name="BinaryDecoder"></a>
   181  ## type [BinaryDecoder](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L17>)
   182  
   183  
   184  
   185  ```go
   186  type BinaryDecoder struct{}
   187  ```
   188  
   189  <a name="BinaryDecoder.DecodeBool"></a>
   190  ### func (BinaryDecoder) [DecodeBool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L164>)
   191  
   192  ```go
   193  func (BinaryDecoder) DecodeBool(b []byte) (bool, int)
   194  ```
   195  
   196  
   197  
   198  <a name="BinaryDecoder.DecodeByte"></a>
   199  ### func (BinaryDecoder) [DecodeByte](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L169>)
   200  
   201  ```go
   202  func (BinaryDecoder) DecodeByte(b []byte) byte
   203  ```
   204  
   205  
   206  
   207  <a name="BinaryDecoder.DecodeBytes"></a>
   208  ### func (BinaryDecoder) [DecodeBytes](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L238>)
   209  
   210  ```go
   211  func (BinaryDecoder) DecodeBytes(b []byte) ([]byte, int, int)
   212  ```
   213  
   214  
   215  
   216  <a name="BinaryDecoder.DecodeDouble"></a>
   217  ### func (BinaryDecoder) [DecodeDouble](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L228>)
   218  
   219  ```go
   220  func (BinaryDecoder) DecodeDouble(b []byte) (float64, int)
   221  ```
   222  
   223  
   224  
   225  <a name="BinaryDecoder.DecodeFixed32"></a>
   226  ### func (BinaryDecoder) [DecodeFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L208>)
   227  
   228  ```go
   229  func (BinaryDecoder) DecodeFixed32(b []byte) (uint32, int)
   230  ```
   231  
   232  
   233  
   234  <a name="BinaryDecoder.DecodeFixed64"></a>
   235  ### func (BinaryDecoder) [DecodeFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L223>)
   236  
   237  ```go
   238  func (BinaryDecoder) DecodeFixed64(b []byte) (uint64, int)
   239  ```
   240  
   241  
   242  
   243  <a name="BinaryDecoder.DecodeFloat32"></a>
   244  ### func (BinaryDecoder) [DecodeFloat32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L213>)
   245  
   246  ```go
   247  func (BinaryDecoder) DecodeFloat32(b []byte) (float32, int)
   248  ```
   249  
   250  
   251  
   252  <a name="BinaryDecoder.DecodeInt32"></a>
   253  ### func (BinaryDecoder) [DecodeInt32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L173>)
   254  
   255  ```go
   256  func (BinaryDecoder) DecodeInt32(b []byte) (int32, int)
   257  ```
   258  
   259  
   260  
   261  <a name="BinaryDecoder.DecodeInt64"></a>
   262  ### func (BinaryDecoder) [DecodeInt64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L188>)
   263  
   264  ```go
   265  func (BinaryDecoder) DecodeInt64(b []byte) (int64, int)
   266  ```
   267  
   268  
   269  
   270  <a name="BinaryDecoder.DecodeSfixed32"></a>
   271  ### func (BinaryDecoder) [DecodeSfixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L203>)
   272  
   273  ```go
   274  func (BinaryDecoder) DecodeSfixed32(b []byte) (int32, int)
   275  ```
   276  
   277  
   278  
   279  <a name="BinaryDecoder.DecodeSfixed64"></a>
   280  ### func (BinaryDecoder) [DecodeSfixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L218>)
   281  
   282  ```go
   283  func (BinaryDecoder) DecodeSfixed64(b []byte) (int64, int)
   284  ```
   285  
   286  
   287  
   288  <a name="BinaryDecoder.DecodeSint32"></a>
   289  ### func (BinaryDecoder) [DecodeSint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L178>)
   290  
   291  ```go
   292  func (BinaryDecoder) DecodeSint32(b []byte) (int32, int)
   293  ```
   294  
   295  
   296  
   297  <a name="BinaryDecoder.DecodeSint64"></a>
   298  ### func (BinaryDecoder) [DecodeSint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L193>)
   299  
   300  ```go
   301  func (BinaryDecoder) DecodeSint64(b []byte) (int64, int)
   302  ```
   303  
   304  
   305  
   306  <a name="BinaryDecoder.DecodeString"></a>
   307  ### func (BinaryDecoder) [DecodeString](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L233>)
   308  
   309  ```go
   310  func (BinaryDecoder) DecodeString(b []byte) (string, int, int)
   311  ```
   312  
   313  
   314  
   315  <a name="BinaryDecoder.DecodeUint32"></a>
   316  ### func (BinaryDecoder) [DecodeUint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L183>)
   317  
   318  ```go
   319  func (BinaryDecoder) DecodeUint32(b []byte) (uint32, int)
   320  ```
   321  
   322  
   323  
   324  <a name="BinaryDecoder.DecodeUint64"></a>
   325  ### func (BinaryDecoder) [DecodeUint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/decode.go#L198>)
   326  
   327  ```go
   328  func (BinaryDecoder) DecodeUint64(b []byte) (uint64, int)
   329  ```
   330  
   331  
   332  
   333  <a name="BinaryEncoder"></a>
   334  ## type [BinaryEncoder](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L8>)
   335  
   336  
   337  
   338  ```go
   339  type BinaryEncoder struct{}
   340  ```
   341  
   342  <a name="BinaryEncoder.EncodeBool"></a>
   343  ### func (BinaryEncoder) [EncodeBool](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L141>)
   344  
   345  ```go
   346  func (BinaryEncoder) EncodeBool(b []byte, v bool) []byte
   347  ```
   348  
   349  encode each proto kind into bytes
   350  
   351  <a name="BinaryEncoder.EncodeByte"></a>
   352  ### func (BinaryEncoder) [EncodeByte](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L148>)
   353  
   354  ```go
   355  func (BinaryEncoder) EncodeByte(b []byte, v byte) []byte
   356  ```
   357  
   358  
   359  
   360  <a name="BinaryEncoder.EncodeBytes"></a>
   361  ### func (BinaryEncoder) [EncodeBytes](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L208>)
   362  
   363  ```go
   364  func (BinaryEncoder) EncodeBytes(b []byte, v []byte) []byte
   365  ```
   366  
   367  
   368  
   369  <a name="BinaryEncoder.EncodeDouble"></a>
   370  ### func (BinaryEncoder) [EncodeDouble](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L200>)
   371  
   372  ```go
   373  func (BinaryEncoder) EncodeDouble(b []byte, v float64) []byte
   374  ```
   375  
   376  
   377  
   378  <a name="BinaryEncoder.EncodeEnum"></a>
   379  ### func (BinaryEncoder) [EncodeEnum](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L152>)
   380  
   381  ```go
   382  func (BinaryEncoder) EncodeEnum(b []byte, v int32) []byte
   383  ```
   384  
   385  
   386  
   387  <a name="BinaryEncoder.EncodeFixed32"></a>
   388  ### func (BinaryEncoder) [EncodeFixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L184>)
   389  
   390  ```go
   391  func (BinaryEncoder) EncodeFixed32(b []byte, v uint32) []byte
   392  ```
   393  
   394  
   395  
   396  <a name="BinaryEncoder.EncodeFixed64"></a>
   397  ### func (BinaryEncoder) [EncodeFixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L196>)
   398  
   399  ```go
   400  func (BinaryEncoder) EncodeFixed64(b []byte, v uint64) []byte
   401  ```
   402  
   403  
   404  
   405  <a name="BinaryEncoder.EncodeFloat32"></a>
   406  ### func (BinaryEncoder) [EncodeFloat32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L188>)
   407  
   408  ```go
   409  func (BinaryEncoder) EncodeFloat32(b []byte, v float32) []byte
   410  ```
   411  
   412  
   413  
   414  <a name="BinaryEncoder.EncodeInt32"></a>
   415  ### func (BinaryEncoder) [EncodeInt32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L156>)
   416  
   417  ```go
   418  func (BinaryEncoder) EncodeInt32(b []byte, v int32) []byte
   419  ```
   420  
   421  
   422  
   423  <a name="BinaryEncoder.EncodeInt64"></a>
   424  ### func (BinaryEncoder) [EncodeInt64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L168>)
   425  
   426  ```go
   427  func (BinaryEncoder) EncodeInt64(b []byte, v int64) []byte
   428  ```
   429  
   430  
   431  
   432  <a name="BinaryEncoder.EncodeSfixed32"></a>
   433  ### func (BinaryEncoder) [EncodeSfixed32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L180>)
   434  
   435  ```go
   436  func (BinaryEncoder) EncodeSfixed32(b []byte, v int32) []byte
   437  ```
   438  
   439  
   440  
   441  <a name="BinaryEncoder.EncodeSfixed64"></a>
   442  ### func (BinaryEncoder) [EncodeSfixed64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L192>)
   443  
   444  ```go
   445  func (BinaryEncoder) EncodeSfixed64(b []byte, v int64) []byte
   446  ```
   447  
   448  
   449  
   450  <a name="BinaryEncoder.EncodeSint32"></a>
   451  ### func (BinaryEncoder) [EncodeSint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L160>)
   452  
   453  ```go
   454  func (BinaryEncoder) EncodeSint32(b []byte, v int32) []byte
   455  ```
   456  
   457  
   458  
   459  <a name="BinaryEncoder.EncodeSint64"></a>
   460  ### func (BinaryEncoder) [EncodeSint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L172>)
   461  
   462  ```go
   463  func (BinaryEncoder) EncodeSint64(b []byte, v int64) []byte
   464  ```
   465  
   466  
   467  
   468  <a name="BinaryEncoder.EncodeString"></a>
   469  ### func (BinaryEncoder) [EncodeString](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L204>)
   470  
   471  ```go
   472  func (BinaryEncoder) EncodeString(b []byte, v string) []byte
   473  ```
   474  
   475  
   476  
   477  <a name="BinaryEncoder.EncodeUint32"></a>
   478  ### func (BinaryEncoder) [EncodeUint32](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L164>)
   479  
   480  ```go
   481  func (BinaryEncoder) EncodeUint32(b []byte, v uint32) []byte
   482  ```
   483  
   484  
   485  
   486  <a name="BinaryEncoder.EncodeUint64"></a>
   487  ### func (BinaryEncoder) [EncodeUint64](<https://github.com/khan-yin/dynamicgo/blob/main/proto/protowire/encode.go#L176>)
   488  
   489  ```go
   490  func (BinaryEncoder) EncodeUint64(b []byte, v uint64) []byte
   491  ```
   492  
   493  
   494  
   495  Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)