Add Codec#{upcast,downcast} for safe casting