Skip to content

Commit 5439ff2

Browse files
committed
feat: migration to dario.cat/xdr
1 parent 5e342c0 commit 5439ff2

File tree

6 files changed

+46
-8
lines changed

6 files changed

+46
-8
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# xdr
22

33
[![Coverage Status](https://img.shields.io/coveralls/imdario/xdr.svg?style=flat)](https://coveralls.io/r/imdario/xdr?branch=master)
4-
[![API Documentation](http://img.shields.io/badge/api-Godoc-blue.svg?style=flat)](http://godoc.org/github.com/imdario/xdr)
5-
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://opensource.org/licenses/MIT)
4+
[![API Documentation](http://img.shields.io/badge/api-Godoc-blue.svg?style=flat)](https://pkg.go.dev/dario.cat/xdr)
5+
[![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
66

7-
This is an XDR marshalling/unmarshalling library. It uses code generation and
8-
not reflection.
7+
This is an XDR marshalling/unmarshalling library. It uses code generation and not reflection.

bench_xdr_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package xdr_test
66

77
import (
8-
"github.com/imdario/xdr"
8+
"dario.cat/xdr"
99
)
1010

1111
/*
@@ -63,6 +63,7 @@ struct XDRBenchStruct {
6363
6464
*/
6565

66+
// XDRSize returns the XDR encoded form's size.
6667
func (o XDRBenchStruct) XDRSize() int {
6768
return 8 + 4 + 4 + 4 +
6869
4 + len(o.Bs0) + xdr.Padding(len(o.Bs0)) +
@@ -72,12 +73,15 @@ func (o XDRBenchStruct) XDRSize() int {
7273
4 + len(o.S1) + xdr.Padding(len(o.S1))
7374
}
7475

76+
// MarshalXDR returns the XDR encoding.
7577
func (o XDRBenchStruct) MarshalXDR() ([]byte, error) {
7678
buf := make([]byte, o.XDRSize())
7779
m := &xdr.Marshaller{Data: buf}
7880
return buf, o.MarshalXDRInto(m)
7981
}
8082

83+
// MustMarshalXDR returns the XDR encoding. MustMarshalXDR
84+
// panics in case of error.
8185
func (o XDRBenchStruct) MustMarshalXDR() []byte {
8286
bs, err := o.MarshalXDR()
8387
if err != nil {
@@ -86,6 +90,7 @@ func (o XDRBenchStruct) MustMarshalXDR() []byte {
8690
return bs
8791
}
8892

93+
// MarshalXDRInto marshals the struct using the provided Marshaller.
8994
func (o XDRBenchStruct) MarshalXDRInto(m *xdr.Marshaller) error {
9095
m.MarshalUint64(o.I1)
9196
m.MarshalUint32(o.I2)
@@ -108,10 +113,14 @@ func (o XDRBenchStruct) MarshalXDRInto(m *xdr.Marshaller) error {
108113
return m.Error
109114
}
110115

116+
// UnmarshalXDR parses the XDR-encoded data and stores the result in the
117+
// struct.
111118
func (o *XDRBenchStruct) UnmarshalXDR(bs []byte) error {
112119
u := &xdr.Unmarshaller{Data: bs}
113120
return o.UnmarshalXDRFrom(u)
114121
}
122+
123+
// UnmarshalXDRFrom unmarshals the struct using the provided Unmarshaller.
115124
func (o *XDRBenchStruct) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
116125
o.I1 = u.UnmarshalUint64()
117126
o.I2 = u.UnmarshalUint32()

cmd/genxdr/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var headerData = `// ***********************************************************
8888
package {{.Package}}
8989
9090
import (
91-
"github.com/imdario/xdr"
91+
"dario.cat/xdr"
9292
)
9393
`
9494

encdec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"testing"
1414
"testing/quick"
1515

16-
"github.com/imdario/xdr"
16+
"dario.cat/xdr"
1717
)
1818

1919
// Contains all supported types

encdec_xdr_test.go

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
package xdr_test
66

77
import (
8-
"github.com/imdario/xdr"
8+
"dario.cat/xdr"
99
)
1010

1111
/*
@@ -99,6 +99,7 @@ struct TestStruct {
9999
100100
*/
101101

102+
// XDRSize returns the XDR encoded form's size.
102103
func (o TestStruct) XDRSize() int {
103104
return 4 + 8 + 4 + 4 + 4 + 4 + 4 + 4 + 8 + 8 +
104105
4 + len(o.BS) + xdr.Padding(len(o.BS)) +
@@ -110,12 +111,15 @@ func (o TestStruct) XDRSize() int {
110111
4 + xdr.SizeOfSlice(o.OSs)
111112
}
112113

114+
// MarshalXDR returns the XDR encoding.
113115
func (o TestStruct) MarshalXDR() ([]byte, error) {
114116
buf := make([]byte, o.XDRSize())
115117
m := &xdr.Marshaller{Data: buf}
116118
return buf, o.MarshalXDRInto(m)
117119
}
118120

121+
// MustMarshalXDR returns the XDR encoding. MustMarshalXDR
122+
// panics in case of error.
119123
func (o TestStruct) MustMarshalXDR() []byte {
120124
bs, err := o.MarshalXDR()
121125
if err != nil {
@@ -124,6 +128,7 @@ func (o TestStruct) MustMarshalXDR() []byte {
124128
return bs
125129
}
126130

131+
// MarshalXDRInto marshals the struct using the provided Marshaller.
127132
func (o TestStruct) MarshalXDRInto(m *xdr.Marshaller) error {
128133
m.MarshalBool(o.B)
129134
m.MarshalUint64(uint64(o.I))
@@ -168,10 +173,14 @@ func (o TestStruct) MarshalXDRInto(m *xdr.Marshaller) error {
168173
return m.Error
169174
}
170175

176+
// UnmarshalXDR parses the XDR-encoded data and stores the result in the
177+
// struct.
171178
func (o *TestStruct) UnmarshalXDR(bs []byte) error {
172179
u := &xdr.Unmarshaller{Data: bs}
173180
return o.UnmarshalXDRFrom(u)
174181
}
182+
183+
// UnmarshalXDRFrom unmarshals the struct using the provided Unmarshaller.
175184
func (o *TestStruct) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
176185
o.B = u.UnmarshalBool()
177186
o.I = int(u.UnmarshalUint64())
@@ -238,25 +247,34 @@ struct EmptyStruct {
238247
239248
*/
240249

250+
// XDRSize returns the XDR encoded form's size.
241251
func (o EmptyStruct) XDRSize() int {
242252
return 0
243253
}
254+
255+
// MarshalXDR returns the XDR encoding.
244256
func (o EmptyStruct) MarshalXDR() ([]byte, error) {
245257
return nil, nil
246258
}
247259

260+
// MustMarshalXDR returns the XDR encoding. MustMarshalXDR
261+
// panics in case of error.
248262
func (o EmptyStruct) MustMarshalXDR() []byte {
249263
return nil
250264
}
251265

266+
// MarshalXDRInto marshals the struct using the provided Marshaller.
252267
func (o EmptyStruct) MarshalXDRInto(m *xdr.Marshaller) error {
253268
return nil
254269
}
255270

271+
// UnmarshalXDR parses the XDR-encoded data and stores the result in the
272+
// struct.
256273
func (o *EmptyStruct) UnmarshalXDR(bs []byte) error {
257274
return nil
258275
}
259276

277+
// UnmarshalXDRFrom unmarshals the struct using the provided Unmarshaller.
260278
func (o *EmptyStruct) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
261279
return nil
262280
}
@@ -283,17 +301,21 @@ struct OtherStruct {
283301
284302
*/
285303

304+
// XDRSize returns the XDR encoded form's size.
286305
func (o OtherStruct) XDRSize() int {
287306
return 4 +
288307
4 + len(o.F2) + xdr.Padding(len(o.F2))
289308
}
290309

310+
// MarshalXDR returns the XDR encoding.
291311
func (o OtherStruct) MarshalXDR() ([]byte, error) {
292312
buf := make([]byte, o.XDRSize())
293313
m := &xdr.Marshaller{Data: buf}
294314
return buf, o.MarshalXDRInto(m)
295315
}
296316

317+
// MustMarshalXDR returns the XDR encoding. MustMarshalXDR
318+
// panics in case of error.
297319
func (o OtherStruct) MustMarshalXDR() []byte {
298320
bs, err := o.MarshalXDR()
299321
if err != nil {
@@ -302,16 +324,21 @@ func (o OtherStruct) MustMarshalXDR() []byte {
302324
return bs
303325
}
304326

327+
// MarshalXDRInto marshals the struct using the provided Marshaller.
305328
func (o OtherStruct) MarshalXDRInto(m *xdr.Marshaller) error {
306329
m.MarshalUint32(o.F1)
307330
m.MarshalString(o.F2)
308331
return m.Error
309332
}
310333

334+
// UnmarshalXDR parses the XDR-encoded data and stores the result in the
335+
// struct.
311336
func (o *OtherStruct) UnmarshalXDR(bs []byte) error {
312337
u := &xdr.Unmarshaller{Data: bs}
313338
return o.UnmarshalXDRFrom(u)
314339
}
340+
341+
// UnmarshalXDRFrom unmarshals the struct using the provided Unmarshaller.
315342
func (o *OtherStruct) UnmarshalXDRFrom(u *xdr.Unmarshaller) error {
316343
o.F1 = u.UnmarshalUint32()
317344
o.F2 = u.UnmarshalString()

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module dario.cat/xdr
2+
3+
go 1.20

0 commit comments

Comments
 (0)