pub enum MaybeProcessedBlock<T, E> {
Raw(Vec<u8>),
Processed(Result<T, E>),
}
Variants§
Raw(Vec<u8>)
A block that’s probably a Node (but we can’t know yet)
It can be a record that suspiciously looks a lot like a node, so we cannot eagerly turn it into a Node. We only know for sure what it is when we actually walk down the MST
Processed(Result<T, E>)
A processed record from a block that was definitely not a Node
Processing has to be fallible because the CAR can have totally-unused blocks, which can just be garbage. since we’re eagerly trying to process record blocks without knowing for sure that they are records, we discard any definitely-not-nodes that fail processing and keep their error in the buffer for them. if we later try to retreive them as a record, then we can surface the error.
If we never needed this block, then we may have wasted a bit of effort trying to process it. Oh well.
There’s an alternative here, which would be to kick unprocessable blocks back to Raw, or maybe even a new RawUnprocessable variant. Then we could surface the typed error later if needed by trying to reprocess.