Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Allow codec to use embedded struct #54

Open
shuse2 opened this issue Feb 12, 2023 · 0 comments
Open

Allow codec to use embedded struct #54

shuse2 opened this issue Feb 12, 2023 · 0 comments

Comments

@shuse2
Copy link
Collaborator

shuse2 commented Feb 12, 2023

Description

For example, below script should be able to produce equivalent outcome of encode/decode when generated.

type Transaction struct {
	SigningTransaction
	ID         codec.Hex   `json:"id"`
	size       int         `json:"-"`
	Signatures []codec.Hex `json:"signatures" fieldNumber:"8"`
}
  • In case of the embedded struct is from another package, it can be ignored

Motivation

Sometimes, there are multiple version of types needs to be defined. For example, Transaction/Block header has signing block/transaction type and ones with signatures.
Currently, they are independent struct, but since properties are the same, it would be nice to be able to declare as an embedded struct

Additional Information

  • codec generation is parsing per file/package. Therefore, it cannot tell if struct from other package is encodable or not
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant