leveldb_xdr.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Copyright (C) 2014 Jakob Borg and Contributors (see the CONTRIBUTORS file).
  2. // All rights reserved. Use of this source code is governed by an MIT-style
  3. // license that can be found in the LICENSE file.
  4. // ************************************************************
  5. // This file is automatically generated by genxdr. Do not edit.
  6. // ************************************************************
  7. package files
  8. import (
  9. "bytes"
  10. "io"
  11. "github.com/calmh/syncthing/xdr"
  12. )
  13. /*
  14. fileVersion Structure:
  15. 0 1 2 3
  16. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  17. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  18. | |
  19. + version (64 bits) +
  20. | |
  21. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  22. | Length of node |
  23. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  24. / /
  25. \ node (variable length) \
  26. / /
  27. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  28. struct fileVersion {
  29. unsigned hyper version;
  30. opaque node<>;
  31. }
  32. */
  33. func (o fileVersion) EncodeXDR(w io.Writer) (int, error) {
  34. var xw = xdr.NewWriter(w)
  35. return o.encodeXDR(xw)
  36. }
  37. func (o fileVersion) MarshalXDR() []byte {
  38. return o.AppendXDR(make([]byte, 0, 128))
  39. }
  40. func (o fileVersion) AppendXDR(bs []byte) []byte {
  41. var aw = xdr.AppendWriter(bs)
  42. var xw = xdr.NewWriter(&aw)
  43. o.encodeXDR(xw)
  44. return []byte(aw)
  45. }
  46. func (o fileVersion) encodeXDR(xw *xdr.Writer) (int, error) {
  47. xw.WriteUint64(o.version)
  48. xw.WriteBytes(o.node)
  49. return xw.Tot(), xw.Error()
  50. }
  51. func (o *fileVersion) DecodeXDR(r io.Reader) error {
  52. xr := xdr.NewReader(r)
  53. return o.decodeXDR(xr)
  54. }
  55. func (o *fileVersion) UnmarshalXDR(bs []byte) error {
  56. var br = bytes.NewReader(bs)
  57. var xr = xdr.NewReader(br)
  58. return o.decodeXDR(xr)
  59. }
  60. func (o *fileVersion) decodeXDR(xr *xdr.Reader) error {
  61. o.version = xr.ReadUint64()
  62. o.node = xr.ReadBytes()
  63. return xr.Error()
  64. }
  65. /*
  66. versionList Structure:
  67. 0 1 2 3
  68. 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  69. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  70. | Number of versions |
  71. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  72. / /
  73. \ Zero or more fileVersion Structures \
  74. / /
  75. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  76. struct versionList {
  77. fileVersion versions<>;
  78. }
  79. */
  80. func (o versionList) EncodeXDR(w io.Writer) (int, error) {
  81. var xw = xdr.NewWriter(w)
  82. return o.encodeXDR(xw)
  83. }
  84. func (o versionList) MarshalXDR() []byte {
  85. return o.AppendXDR(make([]byte, 0, 128))
  86. }
  87. func (o versionList) AppendXDR(bs []byte) []byte {
  88. var aw = xdr.AppendWriter(bs)
  89. var xw = xdr.NewWriter(&aw)
  90. o.encodeXDR(xw)
  91. return []byte(aw)
  92. }
  93. func (o versionList) encodeXDR(xw *xdr.Writer) (int, error) {
  94. xw.WriteUint32(uint32(len(o.versions)))
  95. for i := range o.versions {
  96. o.versions[i].encodeXDR(xw)
  97. }
  98. return xw.Tot(), xw.Error()
  99. }
  100. func (o *versionList) DecodeXDR(r io.Reader) error {
  101. xr := xdr.NewReader(r)
  102. return o.decodeXDR(xr)
  103. }
  104. func (o *versionList) UnmarshalXDR(bs []byte) error {
  105. var br = bytes.NewReader(bs)
  106. var xr = xdr.NewReader(br)
  107. return o.decodeXDR(xr)
  108. }
  109. func (o *versionList) decodeXDR(xr *xdr.Reader) error {
  110. _versionsSize := int(xr.ReadUint32())
  111. o.versions = make([]fileVersion, _versionsSize)
  112. for i := range o.versions {
  113. (&o.versions[i]).decodeXDR(xr)
  114. }
  115. return xr.Error()
  116. }