mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
2c8b627008
Integers are for numbers, enabling arithmetic like subtractions and for loops without getting shot in the foot. Unsigneds are for bitfields. - "int" for numbers that will always be laughably smaller than four billion, and where we don't care about the serialization format. - "int32" for numbers that will always be laughably smaller than four billion, and will be serialized to four bytes. - "int64" for numbers that may approach four billion or will be serialized to eight bytes. - "uint32" and "uint64" for bitfields, depending on required number of bits and serialization format. Likewise "uint8" and "uint16", although rare in this project since they don't exist in XDR. - "int8", "int16" and plain "uint" are almost never useful.
162 lines
4.1 KiB
Go
162 lines
4.1 KiB
Go
// ************************************************************
|
|
// This file is automatically generated by genxdr. Do not edit.
|
|
// ************************************************************
|
|
|
|
package db
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
|
|
"github.com/calmh/xdr"
|
|
)
|
|
|
|
/*
|
|
|
|
fileVersion Structure:
|
|
|
|
0 1 2 3
|
|
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
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| |
|
|
+ version (64 bits) +
|
|
| |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| Length of device |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
/ /
|
|
\ device (variable length) \
|
|
/ /
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
struct fileVersion {
|
|
hyper version;
|
|
opaque device<>;
|
|
}
|
|
|
|
*/
|
|
|
|
func (o fileVersion) EncodeXDR(w io.Writer) (int, error) {
|
|
var xw = xdr.NewWriter(w)
|
|
return o.encodeXDR(xw)
|
|
}
|
|
|
|
func (o fileVersion) MarshalXDR() ([]byte, error) {
|
|
return o.AppendXDR(make([]byte, 0, 128))
|
|
}
|
|
|
|
func (o fileVersion) MustMarshalXDR() []byte {
|
|
bs, err := o.MarshalXDR()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return bs
|
|
}
|
|
|
|
func (o fileVersion) AppendXDR(bs []byte) ([]byte, error) {
|
|
var aw = xdr.AppendWriter(bs)
|
|
var xw = xdr.NewWriter(&aw)
|
|
_, err := o.encodeXDR(xw)
|
|
return []byte(aw), err
|
|
}
|
|
|
|
func (o fileVersion) encodeXDR(xw *xdr.Writer) (int, error) {
|
|
xw.WriteUint64(uint64(o.version))
|
|
xw.WriteBytes(o.device)
|
|
return xw.Tot(), xw.Error()
|
|
}
|
|
|
|
func (o *fileVersion) DecodeXDR(r io.Reader) error {
|
|
xr := xdr.NewReader(r)
|
|
return o.decodeXDR(xr)
|
|
}
|
|
|
|
func (o *fileVersion) UnmarshalXDR(bs []byte) error {
|
|
var br = bytes.NewReader(bs)
|
|
var xr = xdr.NewReader(br)
|
|
return o.decodeXDR(xr)
|
|
}
|
|
|
|
func (o *fileVersion) decodeXDR(xr *xdr.Reader) error {
|
|
o.version = int64(xr.ReadUint64())
|
|
o.device = xr.ReadBytes()
|
|
return xr.Error()
|
|
}
|
|
|
|
/*
|
|
|
|
versionList Structure:
|
|
|
|
0 1 2 3
|
|
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
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
| Number of versions |
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
/ /
|
|
\ Zero or more fileVersion Structures \
|
|
/ /
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
|
|
struct versionList {
|
|
fileVersion versions<>;
|
|
}
|
|
|
|
*/
|
|
|
|
func (o versionList) EncodeXDR(w io.Writer) (int, error) {
|
|
var xw = xdr.NewWriter(w)
|
|
return o.encodeXDR(xw)
|
|
}
|
|
|
|
func (o versionList) MarshalXDR() ([]byte, error) {
|
|
return o.AppendXDR(make([]byte, 0, 128))
|
|
}
|
|
|
|
func (o versionList) MustMarshalXDR() []byte {
|
|
bs, err := o.MarshalXDR()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return bs
|
|
}
|
|
|
|
func (o versionList) AppendXDR(bs []byte) ([]byte, error) {
|
|
var aw = xdr.AppendWriter(bs)
|
|
var xw = xdr.NewWriter(&aw)
|
|
_, err := o.encodeXDR(xw)
|
|
return []byte(aw), err
|
|
}
|
|
|
|
func (o versionList) encodeXDR(xw *xdr.Writer) (int, error) {
|
|
xw.WriteUint32(uint32(len(o.versions)))
|
|
for i := range o.versions {
|
|
_, err := o.versions[i].encodeXDR(xw)
|
|
if err != nil {
|
|
return xw.Tot(), err
|
|
}
|
|
}
|
|
return xw.Tot(), xw.Error()
|
|
}
|
|
|
|
func (o *versionList) DecodeXDR(r io.Reader) error {
|
|
xr := xdr.NewReader(r)
|
|
return o.decodeXDR(xr)
|
|
}
|
|
|
|
func (o *versionList) UnmarshalXDR(bs []byte) error {
|
|
var br = bytes.NewReader(bs)
|
|
var xr = xdr.NewReader(br)
|
|
return o.decodeXDR(xr)
|
|
}
|
|
|
|
func (o *versionList) decodeXDR(xr *xdr.Reader) error {
|
|
_versionsSize := int(xr.ReadUint32())
|
|
o.versions = make([]fileVersion, _versionsSize)
|
|
for i := range o.versions {
|
|
(&o.versions[i]).decodeXDR(xr)
|
|
}
|
|
return xr.Error()
|
|
}
|