Hi, and thank you for maintaining go-toml.
I am evaluating how to decode a TOML discriminated union. A simplified shape is:
[[downloads]]
type = "github_release"
repository = "owner/repo"
tag = "v1.0.0"
asset = "bundle.yaml"
[[downloads]]
type = "github_raw_user_content"
repository = "owner/repo"
revision = "0123456789abcdef"
source = "path/to/file.yaml"
In Rust this can be represented with serde tagged enums, such as #[serde(tag = "type")]. As far as I can tell, go-toml/v2 does not currently provide an equivalent first-class mapping. The available approach is to implement unstable.Unmarshaler and opt in with Decoder.EnableUnmarshalerInterface().
The documentation says that this API does not follow the library semver compatibility guarantees and may change or be removed without a major release. I saw that #873 was completed by #1027, including support for tables and arrays of tables.
Is there a plan to stabilize this interface, possibly by moving Unmarshaler and RawMessage out of unstable? If so, are there known blockers or stability criteria?
If stabilization is not planned, what stable approach would you recommend for discriminated unions: decoding into an intermediate struct or map and dispatching manually, or something else?
Thank you.
Hi, and thank you for maintaining go-toml.
I am evaluating how to decode a TOML discriminated union. A simplified shape is:
In Rust this can be represented with serde tagged enums, such as
#[serde(tag = "type")]. As far as I can tell, go-toml/v2 does not currently provide an equivalent first-class mapping. The available approach is to implementunstable.Unmarshalerand opt in withDecoder.EnableUnmarshalerInterface().The documentation says that this API does not follow the library semver compatibility guarantees and may change or be removed without a major release. I saw that #873 was completed by #1027, including support for tables and arrays of tables.
Is there a plan to stabilize this interface, possibly by moving
UnmarshalerandRawMessageout ofunstable? If so, are there known blockers or stability criteria?If stabilization is not planned, what stable approach would you recommend for discriminated unions: decoding into an intermediate struct or map and dispatching manually, or something else?
Thank you.