Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

Private fields in Response type: how to get at contents? #14

Open
sanmai-NL opened this issue Nov 24, 2017 · 2 comments
Open

Private fields in Response type: how to get at contents? #14

sanmai-NL opened this issue Nov 24, 2017 · 2 comments

Comments

@sanmai-NL
Copy link
Contributor

E.g.: field `0` of tuple-struct `imap::Capabilities` is private. I couldn’t find getters or so for these fields. IMO, the fields in public types should just be public too. (The crate does not have a stable API and needs to be used in practice before even considering adding a lot of ceremony like getters.)

@sanmai-NL
Copy link
Contributor Author

Hm, it appears in mattnenterprise/rust-imap#58 another type was added with the same name (Capabilities, pub struct Capabilities(pub(crate) HashSet<&'static str>);), and it can somehow access the innards of this type in https://github.com/mattnenterprise/rust-imap/blob/5a3ee10b18a2f01e4c14c3982294d53b9a92997c/src/parse.rs#L108-L130 .

@djc
Copy link
Owner

djc commented Nov 25, 2017

Yeah, it seems to me that you can usually get at the contents by just matching against it.

I'm not sure about making fields public. The API guidelines state that things should be private with getters so that you can change implementation details without necessarily changing the API.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants