openpgp::tpk::armor::Encoder is at the wrong location
If we look at https://docs.sequoia-pgp.org/sequoia_openpgp/tpk/index.html, we now see that there is a new module, armor
, that contains a single struct Encoder
, which has a single function new
.
I feel like just by looking at the API documentation, we can see that something is off here. That is not a good use of the hierarchical namespace.
Also, if we picture it being used. Currently, we need to do
openpgp::tpk::armor::Encoder::new(&my_tpk).serialize(...)?;
Whereas if the armor encoder would be more like the TSK
type, as I tried to suggest, we could write:
my_tpk.as_armored().serialize(...)?;
Which I consider much prettier, and easier to discover from browsing the API documentation of TPK, the thing I already have.
There is a second reason why the encoder is at the wrong location, and that is not about API, but about code organization. Every type and function concerned with serialization should be below openpgp/src/serialize
. Then, one day, we can put the whole serialization functionality behind a feature gate, that enables or disables the whole src/serialize
source tree. So, I consider openpgp/src/serialize/tpk.rs
a more appropriate location. If you believe that this file will grow too much, consider using a standalone file.