Don't think this is possible, but would love to be proven wrong!
I would like to stitch together chunks of non-contiguous memory and use them to provide the illusion to a client of an instance of a type allocated upon contiguous memory. That is, if you have some struct
MyStruct with arbitrary internal structure, my service can provide you a
PossiblyDiscontiguous<MyStruct> for you to call methods upon, load from fields, etc. In doing so, I would potentially lazily copy-on-access to make fields of the struct contiguous (allowing making a reference to a field to be a well-formed thing).
The closest thing I can find to what I want is the
DerefMut traits, which basically provide some limited overloading of the
. operator for smart pointers. However,
Deref's method does not provide any indication of the field or method requested, which would be required for my intended purpose.
Is there a crate or language feature that anyone knows of to provide this kind of functionality?