I tried it, so any message can be reinterpret by a proper generic message that has AnyPointer fields in a scheme. Where AnyPointer can be any construction like List<List<AnyStruct>> for example, so i can serialize, store, manipulate, serialize back any message only knowing a generic structure. It works well.
I saw an example of a list truncation:
auto orphan = myStruct.disownMyList();
orphan.truncate(size);
myStruct.adoptMyList(kj::mv(orphan));
though i haven't found how to do so for AnyList<AnyStruct> structure, so it was necessary to calculate m_filledEntries before the creation of the list:
auto entriesBuilder = AnyPointer::Builder(r1.getEntries()).initAsListOfAnyStruct(m_entrySize, m_filledEntries, m_filledEntries);
for (size_t i = 0, j = 0; i < m_entries.size(); ++i) {
if (!m_entries[i].isBlank) {
auto dataSection = entriesBuilder[j++].getDataSection();
std::copy(m_entries[i].buff.begin(), m_entries[i].buff.begin() + m_entrySize, dataSection.begin());
}
}
Now i'm trying to tell a server that uses generic messages that in a struct of a received message there is a key on the byte offset X with the size N. The server reads a special message that convey this information. So the server can keep a data snapshot in a hash key-value storage and manipulate entries by the the byte-key. The problem is how to find the offset and size of the specific key field to encode in the message with settings. It seems all these things are deeply hidden.
Any ideas maybe?
Thanks for your help.