-
Notifications
You must be signed in to change notification settings - Fork 499
Expose UnknownStorage.data as a r/o Data. #340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| public struct UnknownStorage: Equatable { | ||
| internal var data = Data() | ||
| public private(set) var data = Data() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal(set)? (Sorry, didn't realize it was originally internal, not private, when we chatted offline.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna go with private for the moment because we don't actually want to force set the data, it should be always coming in via append()
Gives developers a way to tell something is there, even if we don't really have help for parsing it.
5ae36a5 to
d04b6a9
Compare
|
Update tests where I was looking at unknowns to be much simpler by using this. |
tbkka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
This is a good change: |
For now, maybe—but we eventually want a way for users to look at the field numbers and wire-format values individually like the other languages allow. But with the implementation we have now, exposing the data is better than exposing nothing, since building that other API would take longer and I don't think we need it for 1.0. |
Absolutely. Constructing such a view does carry a CPU and memory cost, of course, so I would prefer to make that explicit and not construct such a view until the user actually asks for it. The |
|
Yep, building the smart view lazily for the user should be trivial. |
Gives developers a way to tell something is there, even if we
don't really have help for parsing it.