Summary
Adding an ExpectedTable variant to ExpectedType so table-shaped accessors (e.g. the table_keys helper proposed in #23) can return a precise WrongType error when a path resolves to a non-table value.
Why this is breaking (and therefore 2.0)
ExpectedType documents its variants as part of the stable public API:
Variants are part of the stable public API. Adding, removing, or renaming a variant is treated as a breaking change.
So introducing ExpectedTable is a major-version change. Until then, accessors like table_keys (#23) must work around the gap — either reusing an existing ExpectedType value (inaccurate), collapsing the non-table case into KeyNotFound (lossy), or returning a bare List(String) and sidestepping GetError entirely.
Proposed change
pub type ExpectedType {
ExpectedString
ExpectedInt
ExpectedBool
ExpectedFloat
ExpectedDate
ExpectedTime
ExpectedDateTime
ExpectedTable // new
}
This lets table_keys (and any future table-shaped accessor) return:
- missing key ->
Error(KeyNotFound(path))
- present but not a table ->
Error(WrongType(path, ExpectedTable))
matching the existing get_* family's error style.
Related
Summary
Adding an
ExpectedTablevariant toExpectedTypeso table-shaped accessors (e.g. thetable_keyshelper proposed in #23) can return a preciseWrongTypeerror when a path resolves to a non-table value.Why this is breaking (and therefore 2.0)
ExpectedTypedocuments its variants as part of the stable public API:So introducing
ExpectedTableis a major-version change. Until then, accessors liketable_keys(#23) must work around the gap — either reusing an existingExpectedTypevalue (inaccurate), collapsing the non-table case intoKeyNotFound(lossy), or returning a bareList(String)and sidesteppingGetErrorentirely.Proposed change
This lets
table_keys(and any future table-shaped accessor) return:Error(KeyNotFound(path))Error(WrongType(path, ExpectedTable))matching the existing
get_*family's error style.Related