I've been looking at how to add width limiting and other options to stellar-xdr, and I don't see a good way to add additional options with the existing pattern that's been used when we added depth limiting with DepthLimiter/DepthLimitedRead/DepthLimitedWrite.
If we followed the same pattern we're using now, we'd add a new trait, and two impls for each trait, and then pass around an impl DepthLimitedRead<R> + WidthLimitedRead<R> + OtherOptionRead<R> which I'm not actually sure is possible because of there are limitations on combining traits.
We're using the Rust trait and type system to add additional options to a Read, which is pretty complicated, but we could just pass those options around as a simple struct.
So I'm thinking of removing the DepthLimiter type system, and replacing it with every read_xdr accepting a r: impl Read and a o: Options, where Options is a simple struct that contains any remaining depth, remaining width, or other options.
Thoughts?