Integer type policy
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.
This commit is contained in:
17
Godeps/_workspace/src/github.com/syncthing/protocol/message.go
generated
vendored
17
Godeps/_workspace/src/github.com/syncthing/protocol/message.go
generated
vendored
@@ -1,6 +1,5 @@
|
||||
// Copyright (C) 2014 The Protocol Authors.
|
||||
|
||||
//go:generate -command genxdr go run ../../Godeps/_workspace/src/github.com/calmh/xdr/cmd/genxdr/main.go
|
||||
//go:generate genxdr -o message_xdr.go message.go
|
||||
|
||||
package protocol
|
||||
@@ -18,8 +17,8 @@ type FileInfo struct {
|
||||
Name string // max:8192
|
||||
Flags uint32
|
||||
Modified int64
|
||||
Version uint64
|
||||
LocalVersion uint64
|
||||
Version int64
|
||||
LocalVersion int64
|
||||
Blocks []BlockInfo
|
||||
}
|
||||
|
||||
@@ -60,7 +59,7 @@ func (f FileInfo) HasPermissionBits() bool {
|
||||
|
||||
type BlockInfo struct {
|
||||
Offset int64 // noencode (cache only)
|
||||
Size uint32
|
||||
Size int32
|
||||
Hash []byte // max:64
|
||||
}
|
||||
|
||||
@@ -71,8 +70,8 @@ func (b BlockInfo) String() string {
|
||||
type RequestMessage struct {
|
||||
Folder string // max:64
|
||||
Name string // max:8192
|
||||
Offset uint64
|
||||
Size uint32
|
||||
Offset int64
|
||||
Size int32
|
||||
Hash []byte // max:64
|
||||
Flags uint32
|
||||
Options []Option // max:64
|
||||
@@ -80,7 +79,7 @@ type RequestMessage struct {
|
||||
|
||||
type ResponseMessage struct {
|
||||
Data []byte
|
||||
Error uint32
|
||||
Error int32
|
||||
}
|
||||
|
||||
type ClusterConfigMessage struct {
|
||||
@@ -107,7 +106,7 @@ type Folder struct {
|
||||
type Device struct {
|
||||
ID []byte // max:32
|
||||
Flags uint32
|
||||
MaxLocalVersion uint64
|
||||
MaxLocalVersion int64
|
||||
}
|
||||
|
||||
type Option struct {
|
||||
@@ -117,7 +116,7 @@ type Option struct {
|
||||
|
||||
type CloseMessage struct {
|
||||
Reason string // max:1024
|
||||
Code uint32
|
||||
Code int32
|
||||
}
|
||||
|
||||
type EmptyMessage struct{}
|
||||
|
||||
Reference in New Issue
Block a user