Skip to content

Make Bounds type safe #462

@maurolacy

Description

@maurolacy

Current Bounds take a Vec<u8> as parameter, which is not related to the types the bound will apply to. This forces the user to build the proper bound manually, which requires knowledge of the internal structure used to store the different types. This is particularly annoying with composite keys, where a helper (joined_key) must be used to concatenate the key components.

Let's improve on this by making Bound type-safe. This may be tricky to do, as currently Bound is independent of the map-like structure it can be applied to.

There's a key() (index_key in the case if indexed maps) method in map-like structs, that can be used as an alternative to building the key manually. But, it only supports the full key, not the prefix / sub-prefix keys. An alternative could be to extend this with a couple of prefix_key() and sub_prefix_key() helpers.

Let's evaluate first if we can do better than that.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions