Skip to content

Add Initialize/Inhabited (TryFromBytes super-trait) #2748

@joshlf

Description

@joshlf

A number of desired features require knowledge of the recursive layout of a type down to individual fields. KnownLayout is not recursive (e.g. you can derive KnownLayout on a sized type whose fields are not KnownLayout), and so we cannot use KnownLayout without a semver breaking change. Besides, KnownLayout is philosophically the wrong place for these features.

These features include:

Instead, we should add a super-trait to TryFromBytes which has a recursive requirement (just like TryFromBytes) but which is not as heavy-weight as TryFromBytes (which requires deriving an entire validator) and does not expose the ability to construct a type to users outside of a module (which is something that an author may wish to avoid). Naming TBD (Initialize and Inhabited were both proposed, but other names may be better).

Open questions

  • Could we migrate any functionality from KnownLayout, thus unlocking this functionality a) as a dependency of this new trait or, b) for types which KnownLayout can't support?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions