• Daniel Martí's avatar
    codec/raw: implement the raw codec · 7e692244
    Daniel Martí authored
    It's small, it's simple, and it's already widely used as part of unixfs.
    So there's no reason it shouldn't be part of go-ipld-prime.
    
    The codec is tiny, but has three noteworthy parts: the Encode and Decode
    funcs, the cidlink multicodec registration, and the Bytes method
    shortcut. Each of these has its own dedicated regression test.
    
    I'm also using this commit to showcase the use of quicktest instead of
    go-wish. The result is extremely similar, but with less dot-import
    magic. For example, if I remove the Bytes shortcut in Decode:
    
    	--- FAIL: TestDecodeBuffer (0.00s)
    	    codec_test.go:115:
    	        error:
    	          got non-nil error
    	        got:
    	          e"could not decode raw node: must not call Read"
    	        stack:
    	          /home/mvdan/src/ipld/codec/raw/codec_test.go:115
    	            qt.Assert(t, err, qt.IsNil)
    7e692244
codec.go 1.91 KB