I went through the documentation for it and had a couple of questions:
In the first example as shown below
we can directly set to and retrieve from stable memory using the get_var and set_var functions provided. Will this support all the collections from the standard library or is it only limited to specific data structures?
how does the calling code determine the from and to values to be passed? Is there some adjoining index mechanism that is available to the calling code that can help it determine what to pass?
Are there plans to create stable variants of other data structures such as a BTreeMap or a Set?
How does one handle changes to the schema? If I were to store a User struct with name and age in a SHashMap today and then later decide to add another field gender to the User struct later, how would I migrate the existing collection?
Again, thank you for sharing your expertise. Highly grateful for the insights
Any structure that implements CandidType trait will work fine. So any standard type that implements it should also work out of the box. For those types, which don’t implement this trait (as BinaryHeap, for example) you may just want to make a wrapper type that will implement it.
Oh, no. These “from” and “to” variables are just regular code. There is no notion of pagination in ic-stable-collections.
It is possible to add a support for HashSet pretty quickly. But BTrees seem quite tricky for me to implement, so it would take some time. But, yes, BTree-based collections are the first in the queue.
There are options. You can define your struct as a versioned box beforehand. E.g.