Conversation
|
Is this going to get a For the |
I was thinking about it and I would love to have something like
How does the registry solves this problem ? You still need to know hat codec to use don't you ? What I have been thinking would be nice to have some representation of block + codec info let's call it a multiblock for now. That would enable composition just like with multibase decoders. Maybe we could have something like this ? interface MultiBlockEncoder<Code> {
encode(input:Multiblock<Code>):EncodedMultiblock<Code>
or(other:MultiblockEncoder<OtherCode>):MultiblockEncoder<Code|OtherCode>
}
interface MultiBlockDecoder<Code> {
decode(input:EncodedMultiblock<Code>):Multiblock<Code>
or(other:MultiBlockDecoder<OtherCode>):MultiBlockDecoder<Code>
}
type Multiblock<Code> = {
code: Code
data: any
}
type EncodedMultiblock<Code> = {
code: Code,
bytes: Uint8Array
}This would enable composeincg both encoders and decoders e.g.: const codec = dagRaw.or(dagJSON).or(dagCbor).or(dagPb)
codec.encode({ code: dagCbor.code, data: { ... } })
codec.encode({ code: dagPb.code, data: {...} })This could also work just fine with js-block and |
So given the CAR encoding: If we can formalize this following byte range I also have to highlight that need for CID+Block abstraction is something I have run and asked for myself in the past. I think back than I was proposing to introduce notion of "inline blocks". |
59449e7 to
5e9a433
Compare
|
@mikeal I have got test coverage to here Only places it seems to complain about are the throw statements in I have also moved |
BREAKING CHANGE! no more basics export
This supersedes #35. It vendors
base-xand bundles base32 & base58btc codecs with CID implementation so no dependency injections will be necessary. All the tests pass now, but I need to spend bit more time on code coverage.