specs icon indicating copy to clipboard operation
specs copied to clipboard

`raw` codec

Open achingbrain opened this issue 6 years ago • 3 comments

Is the raw codec documented anywhere? I want to link to it from a spec document but there doesn't seem to be anything in the block-layer/codecs directory.

I guess it could be as simple as "It's an opaque stream of bytes".

achingbrain avatar Nov 14 '19 16:11 achingbrain

:thumbsup: we need a block-layer/codecs/raw.md and it shouldn't be too hard, I'll try and remember to get to this soon.

rvagg avatar Jan 01 '20 02:01 rvagg

Here's a question for the spec. Are zero bytes valid in the "raw" codec? Nearly all other codecs should reject empty input on decode, I think. Take JSON and CBOR including their "DAG" variants, for example - a value/node in either can't be encoded as zero bytes.

I think the "raw" codec is special enough that it might be OK for it to be zero bytes. But also, it probably makes no sense for an IPLD block to have zero length.

mvdan avatar Sep 04 '21 16:09 mvdan

dag-pb has a special case for zero bytes, it's a form we have to recognise, so there's an existing case for it. I would say that it's valid for raw to have zero bytes since a zero length byte array is a perfectly reasonable programmatic construct. The difference with dag-cbor and dag-json is that there's no clear connection between a zero length block and what the data model should be representing for it, since both of those require something even for "empty" recursives and bytes.

rvagg avatar Sep 06 '21 01:09 rvagg