I've been trying to implement BinaryEncoder
/BinaryDecoder
, and decided that keyed container will be unsupported (I could just ignore the key, but that'd be too dangerous for my maintenance). So I've been throwing exception everywhere KeyedDecodingContainer
is needed. So far so good.
The problem is that all of Encoder
container operations is non-throw
ing. So I setup an UnsupportedContainer
that throws whenever any encode(_:)
is called.
struct UnsupportedContainer<Key>: Keyed, Unkeyed, SingleValue {
...
}
but it feels like I'm doing a lot of unnecessary work.
Is there a better way to setup a Encoder
/Decoder
with unsupported containers?