-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration free implementation #36
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-x
and 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.