Description
#647 introduced typed access to SideMetadataSpec
. All the side metadata access methods require a type parameter to specify the metadata value, such as load<V: MetadataType>() -> V
, or store<V: MetadataValue>(val: V)
.
As each side metadata spec defines its metadata value type, we could embed the type parameter to SideMetadataSpec
, such as SideMetadataSpec<MetadataValue>
. In that case, we do not need to supply a type when calling each access method.
One problem is that we cannot put, for example, SideMetadataSpec<u8>
and SideMetadataSpec<u16>
to the same array. In most cases, when we access (read/write) to side metadata, we access that one particular side metadata spec, thus we do not iterate through a vector to access them. But we do have a few use cases that we need to iterate through different side metadata specs, for example, when we mmap all the side metadata for a newly acquired memory region. In that case, we can have a new trait like SideMetadataMmapper
, and iterate through Vec<Box<dyn SideMetadataMmapper>>
to mmapping.