Skip to content
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

Fix missing re-exports #2031

Merged
merged 3 commits into from
Nov 13, 2024
Merged

Conversation

gretchenfrage
Copy link
Contributor

Closes #2012

In that issue, we noted that there doesn't seem to exists any automated tooling to automatically detect types from external crates which are visible in a crate's public API but which the crate does not re-export. So I went ahead and attempted to create such a tool: [cargo should-be-public-checker]. It's still pretty crude right now but it was enough to detect a handful of items that I confirmed were missing reexports in Quinn and proto. That said, it's possible that there are some things it missed.

should-be-public-checker output for quinn-proto (on main):

visible but not importable:
- quinn_proto::Chunk::bytes::Bytes
- quinn_proto::ClientConfig::with_root_certificates::RootCertStore
- quinn_proto::ClientConfig::with_root_certificates::VerifierBuilderError
- quinn_proto::ConnectionClose::frame_type::Type
- quinn_proto::ConnectionHandle::`<_ as Index<Some(AngleBracketed { args: [Type(ResolvedPath(Path { name: "ConnectionHandle", id: Id(4627), args: Some(AngleBracketed { args: [], constraints: [] }) }))], constraints: [] })>>`::Output::ConnectionMeta
- quinn_proto::ConnectionId::from_buf::Buf
- quinn_proto::PartialDecode::new::BytesMut
- quinn_proto::ServerConfig::with_single_cert::CertificateDer
- quinn_proto::ServerConfig::with_single_cert::PrivateKeyDer
- quinn_proto::crypto::rustls::HandshakeData::negotiated_cipher_suite::CipherSuite
- quinn_proto::crypto::rustls::QuicClientConfig::with_initial::ClientConfig
- quinn_proto::crypto::rustls::QuicServerConfig::with_initial::ServerConfig
- quinn_proto::crypto::rustls::QuicServerConfig::with_initial::Suite
- quinn_proto::crypto::rustls::TlsSession::`<_ as VZip<Some(AngleBracketed { args: [Type(Generic("V"))], constraints: [] })>>`::MultiLane
- quinn_proto::transport_parameters::TransportParameters::write::BufMut

should-be-public-checker output for quinn (on main):

visible but not importable:
- quinn::ApplicationClose::reason::Bytes
- quinn::ClientConfig::initial_dst_cid_provider::ConnectionId
- quinn::ClientConfig::initial_dst_cid_provider::ConnectionId::from_buf::Buf
- quinn::ConnectionClose::error_code::Code
- quinn::ConnectionClose::frame_type::Type
- quinn::ConnectionStats::frame_tx::FrameStats
- quinn::ConnectionStats::path::PathStats
- quinn::ConnectionStats::udp_tx::UdpStats
- quinn::EndpointConfig::cid_generator::ConnectionIdGenerator
- quinn::SendStream::write_chunks::Written
- quinn::StreamId::new::Dir
- quinn::StreamId::new::Side
- quinn::Transmit::ecn::EcnCodepoint
- quinn::VarInt::from_u64::VarIntBoundsExceeded
- quinn::crypto::CryptoError::`<_ as VZip<Some(AngleBracketed { args: [Type(Generic("V"))], constraints: [] })>>`::MultiLane
- quinn::rustls::ConfigSide::Sealed
- quinn::rustls::RootCertStore::roots::TrustAnchor
- quinn::rustls::client::EchConfig::new::EchConfigListBytes
- quinn::rustls::client::ServerCertVerifierBuilder::with_crls::CertificateRevocationListDer
- quinn::rustls::client::Tls13ClientSessionValue::`<_ as Deref<Some(AngleBracketed { args: [], constraints: [] })>>`::Target::ClientSessionCommon
- quinn::rustls::client::verify_server_cert_signed_by_trust_anchor::CertificateDer
- quinn::rustls::client::verify_server_cert_signed_by_trust_anchor::SignatureVerificationAlgorithm
- quinn::rustls::client::verify_server_cert_signed_by_trust_anchor::UnixTime
- quinn::rustls::client::verify_server_name::ServerName
- quinn::rustls::crypto::cipher::OutboundOpaqueMessage::read::MessageError
- quinn::rustls::crypto::cipher::OutboundOpaqueMessage::read::Reader
- quinn::rustls::crypto::cipher::PlainMessage::payload::Payload
- quinn::rustls::crypto::hpke::HpkeSuite::kem::HpkeKem
- quinn::rustls::crypto::hpke::HpkeSuite::sym::HpkeSymmetricCipherSuite
- quinn::rustls::crypto::hpke::HpkeSuite::sym::HpkeSymmetricCipherSuite::aead_id::HpkeAead
- quinn::rustls::crypto::hpke::HpkeSuite::sym::HpkeSymmetricCipherSuite::kdf_id::HpkeKdf
- quinn::rustls::crypto::ring::sign::any_ecdsa_type::PrivateKeyDer
- quinn::rustls::crypto::ring::sign::any_eddsa_type::PrivatePkcs8KeyDer
- quinn::rustls::crypto::verify_tls13_signature_with_raw_key::SubjectPublicKeyInfoDer
- quinn::rustls::server::ClientHello::server_cert_types::CertificateType
- quinn::rustls::unbuffered::TransmitTlsData::may_encrypt_early_data::MayEncryptEarlyData

Summary of changes:

  • quinn_proto::frame::Type becomes public. So, in addition to simply re-exporting it:
    • Renamed it to FrameType
    • Added doc comment
    • Made its associated constants pub(crate) rather than pub
  • In terms of crate re-exports: Quinn already re-exports rustls and udp. Following this trend, I also added re-export of rustls to proto, and re-export of bytes to both.
  • I changed crate re-exports from pub use to pub extern crate. I'm fine changing this back if you like, but I think this is better because it's more clear that it's more clear that it's a crate being re-exported.
  • Other than that, simply pub used all the missing items.

Of course, fixing the missing re-exports in rustls is out of scope, and the thing about MultiLane is some irrelevant blanket-impl.

@djc
Copy link
Member

djc commented Nov 11, 2024

Very cool that you created a tool for this, definitely good to improve on this in a more structural way!

  • I changed crate re-exports from pub use to pub extern crate. I'm fine changing this back if you like, but I think this is better because it's more clear that it's more clear that it's a crate being re-exported.

This definitely does not seem like an improvement, IMO extern crate should basically never be used in modern Rust, and I think it's plenty clear enough that these are crate re-exports. If not, just add some comments.

I don't think we should re-export bytes. It is a 1.0 dependency that IMO is pretty unlikely to ever get a semver-incompatible bump, so there's not the same benefit like with rustls that matching the used version is hard.

My remaining question here is, are these changes semver-compatible? (In particular, the renaming of frame::Type.)

@gretchenfrage
Copy link
Contributor Author

If not, just add some comments.

Unfortunately, doc comments on re-export items doesn't seem to be working with rustdoc? It's fine, though.

quic_proto::frame::Type should be publically re-exported. This commit
renames the it to a name more befitting of a public type.
@gretchenfrage
Copy link
Contributor Author

:)

  • Removed reexport of bytes.
  • Changed pub extern crate back to pub use.

My remaining question here is, are these changes semver-compatible? (In particular, the renaming of frame::Type.)

quinn_proto::frame::Type is not importable on main. the struct Type is pub, but the mod frame is default visibility, and Type is never re-exported. You can confirm that in the current docs.rs for eg. ConnectionClose, the Type in frame_type: Option<Type> is not a link, and Type cannot be found by searching. Therefore, renaming it should not cause semver problems.

The only changes other than that rename are adding new re-exports. I don't imagine this is something that's considered to cause semver problems.

It may be hard to tell at a glance because cargo fmt alphabetizes it, but the new re-exports added to Quinn in the last commit are:

  • quinn_proto::Dir
  • quinn_proto::Side
  • quinn_proto::ConnectionId
  • quinn_proto::Written
  • quinn_proto::TransportErrorCode
  • quinn_proto::FrameStats
  • quinn_proto::VarIntBoundsExceeded
  • quinn_proto::PathStats
  • quinn_proto::UdpStats
  • quinn_proto::ConnectionIdGenerator
  • quinn_proto::EcnCodepoint
  • quinn_proto::FrameType

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me!

(If you want to do a similar pass for rustls, that would be much appreciated!)

Copy link
Collaborator

@Ralith Ralith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Would be cool to have this running in CI.

@Ralith Ralith added this pull request to the merge queue Nov 13, 2024
Merged via the queue into quinn-rs:main with commit eebccff Nov 13, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Some types appear in quinn's public API which are not accessible through quinn directly
3 participants