hdf5-rust
hdf5-rust copied to clipboard
Support for DSTs?
I recently need to write some DST (dynamically sized type) data to HDF5. The size of a DST struct is dynamically known, and also fixed because once determined, it won't change anymore. However, I know that DST in rust is not that easy to use, and I don't ask for many changes.
I would just suggest that changing H5Type::type_descriptor()
to H5Type::type_descriptor(&self)
. As the size of a DST struct is dynamically known, we can get the size with &self
, and therefore can construct an instance of TypeDescriptor
.
Although this is a small suggestion, it may require a lot changes (I haven't tried). Would you consider such change? If you like it, I'd like to open a PR and try to implement it.
I have a gut feeling this would be a major change, but you should prototype this to find out. Could be some other approach to dynamic types would be preferable instead of trying to fit this into the existing API
DST cannot impl H5Type
now because it is !Sized
, and all generic APIs need the type implement H5Type
. Another approach is to provide some unsafe APIs enable users passing TypeDescriptor
and raw pointer (DST reference is fat pointer) themselves.
I'm working on extending the APIs: https://github.com/Berrysoft/hdf5-ext/tree/master/hdf5-dst
@Berrysoft I know this issue is a little dated, but I was wondering how well your approach worked? This feature would be very useful for me, and I might be able to contribute some time to it if any more work is needed to integrate it.
@watsaig You can try the repo (hdf5-ext) I linked above. I use it in production:)
However I forgot to publish them, and the docs are not complete. Will publish them ASAP. If you would like my approach, we can discuss in my repo:)
Great to hear, and thanks for the quick reply!