Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ld
go-codec-dagpb
Commits
035ab815
Unverified
Commit
035ab815
authored
Dec 09, 2020
by
Rod Vagg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s/dag-cbor/dag-pb/gi
parent
f75a516a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
marshal.go
marshal.go
+4
-4
multicodec.go
multicodec.go
+6
-6
unmarshal.go
unmarshal.go
+2
-2
No files found.
marshal.go
View file @
035ab815
...
...
@@ -19,10 +19,10 @@ type pbLink struct {
hasTsize
bool
}
// Marshal provides an IPLD codec encode interface for DAG-
CBOR
data. Provide a
// conforming Node and a destination for bytes to marshal a DAG-
CBOR
IPLD Node.
// The Node must strictly conform to the DAG-
CBOR
schema
// (https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-
cbor
.md).
// Marshal provides an IPLD codec encode interface for DAG-
PB
data. Provide a
// conforming Node and a destination for bytes to marshal a DAG-
PB
IPLD Node.
// The Node must strictly conform to the DAG-
PB
schema
// (https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-
pb
.md).
// For safest use, build Nodes using the Type.PBNode type.
func
Marshal
(
inNode
ipld
.
Node
,
out
io
.
Writer
)
error
{
// Wrap in a typed node for some basic schema form checking
...
...
multicodec.go
View file @
035ab815
...
...
@@ -17,8 +17,8 @@ func init() {
cidlink
.
RegisterMulticodecEncoder
(
0x70
,
Encoder
)
}
// Decoder provides an IPLD codec decode interface for DAG-
CBOR
data. Provide a
// compatible NodeAssembler and a byte source to unmarshal a DAG-
CBOR
IPLD Node.
// Decoder provides an IPLD codec decode interface for DAG-
PB
data. Provide a
// compatible NodeAssembler and a byte source to unmarshal a DAG-
PB
IPLD Node.
// Use the NodeAssembler from the PBNode type for safest construction
// (Type.PBNode.NewBuilder()). A Map assembler will also work.
// This function is registered via the go-ipld-prime link loader for multicodec
...
...
@@ -27,10 +27,10 @@ func Decoder(na ipld.NodeAssembler, r io.Reader) error {
return
Unmarshal
(
na
,
r
)
}
// Encoder provides an IPLD codec encode interface for DAG-
CBOR
data. Provide a
// conforming Node and a destination for bytes to marshal a DAG-
CBOR
IPLD Node.
// The Node must strictly conform to the DAG-
CBOR
schema
// (https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-
cbor
.md).
// Encoder provides an IPLD codec encode interface for DAG-
PB
data. Provide a
// conforming Node and a destination for bytes to marshal a DAG-
PB
IPLD Node.
// The Node must strictly conform to the DAG-
PB
schema
// (https://github.com/ipld/specs/blob/master/block-layer/codecs/dag-
pb
.md).
// For safest use, build Nodes using the Type.PBNode type.
// This function is registered via the go-ipld-prime link loader for multicodec
// code 0x70 when this package is invoked via init.
...
...
unmarshal.go
View file @
035ab815
...
...
@@ -14,8 +14,8 @@ import (
// malformed data
var
ErrIntOverflow
=
xerrors
.
Errorf
(
"protobuf: varint overflow"
)
// Unmarshal provides an IPLD codec decode interface for DAG-
CBOR
data. Provide
// a compatible NodeAssembler and a byte source to unmarshal a DAG-
CBOR
IPLD
// Unmarshal provides an IPLD codec decode interface for DAG-
PB
data. Provide
// a compatible NodeAssembler and a byte source to unmarshal a DAG-
PB
IPLD
// Node. Use the NodeAssembler from the PBNode type for safest construction
// (Type.PBNode.NewBuilder()). A Map assembler will also work.
func
Unmarshal
(
na
ipld
.
NodeAssembler
,
in
io
.
Reader
)
error
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment