Skip to content

Review foreign types in public APIs #3177

@Frando

Description

@Frando

We currently expose quite a lot of types from dependencies in the pubic API of iroh. We should review that list before 1.0.
For some types from widely used crates with a 1.0 release, e.g. bytes::Bytes , we're likely fine with exposing them.

For types from pre-1.0 crates, leaving them in the public API of iroh means we cannot update the crate (apart from patch-level changes) without a semver breaking change in iroh.

There's a tool called cargo-check-external-types which produces a list of foreign types that are used in public APIs.

Here's the list on main as of 2026-01-27.

These crates are excluded (they are at 1.0 and very "base" crates, or owned by us and we know that they'll be part of the public API):

allowed_external_types = [
    "bytes::*",
    "iroh_base::*",
    "iroh_metrics::*",
    "iroh_quinn::*",
    "iroh_quinn_proto::*",
    "iroh_relay::*",
    "n0_error::*",
    "n0_watcher::*",
    "serde::*",
    "serde_core::*",
    "url::*",
]

This is the remaining list of external types. The table is a unification of the results for iroh-base, iroh-relay, and iroh. "Used in" is only the first usage site, there's usually more (run the tool yourself to see the full list).

Crate Version Type Used In
data_encoding 2.10.0 data_encoding::DecodeError iroh-base/src/key.rs:206:1
ed25519_dalek 3.0.0-pre.1 ed25519_dalek::errors::SignatureError iroh-base/src/key.rs:214:9
futures_core 0.3.31 futures_core::stream::Stream iroh-relay/src/client.rs:381:1
futures_lite 2.6.1 futures_lite::future::Boxed iroh-relay/src/dns.rs:42:5
futures_lite 2.6.1 futures_lite::stream::Boxed iroh/src/address_lookup.rs:302:5
futures_sink 0.3.31 futures_sink::Sink iroh-relay/src/client.rs:389:1
hickory_resolver 0.25.2 hickory_resolver::error::ResolveError iroh-relay/src/dns.rs:65:1
http 1.4.0 http::header::name::HeaderName iroh-relay/src/http.rs:22:1
http 1.4.0 http::header::value::HeaderValue iroh-relay/src/protos/handshake.rs:170:31
http 1.4.0 http::header::value::InvalidHeaderValue iroh-relay/src/server.rs:277:22
http 1.4.0 http::status::StatusCode iroh-relay/src/client.rs:117:33
hyper 1.8.1 hyper::error::Error iroh-relay/src/client.rs:123:9
ipnet 2.11.0 ipnet::ipnet::PrefixLenError iroh/src/endpoint/bind.rs:235:1
netwatch 0.13.0 netwatch::netmon::Error iroh/src/socket.rs:732:27
num_enum 0.7.5 num_enum::TryFromPrimitive iroh-relay/src/protos/common.rs:16:65
num_enum 0.7.5 num_enum::TryFromPrimitiveError iroh-relay/src/protos/common.rs:16:65
pkarr 5.0.2 pkarr::client::Client iroh/src/address_lookup/pkarr/dht.rs:140:5
pkarr 5.0.2 pkarr::keys::PublicKeyError iroh/src/address_lookup/pkarr.rs:87:9
pkarr 5.0.2 pkarr::signed_packet::SignedPacket iroh-relay/src/endpoint_info.rs:403:5
pkarr 5.0.2 pkarr::signed_packet::SignedPacketBuildError iroh-relay/src/endpoint_info.rs:57:9
pkarr 5.0.2 pkarr::signed_packet::SignedPacketVerifyError iroh/src/address_lookup/pkarr.rs:92:9
portmapper 0.13.0 portmapper::metrics::Metrics iroh/src/metrics.rs:26:5
postcard 1.1.3 postcard::error::Error iroh-relay/src/protos/handshake.rs:166:9
rand_core 0.9.5 rand_core::CryptoRng iroh-base/src/key.rs:284:5
reloadable_core 0.1.0 reloadable_core::Loader iroh-relay/src/server/resolver.rs:28:1
reloadable_state 0.1.0 reloadable_state::Reloadable iroh-relay/src/server/resolver.rs:89:5
reqwest 0.12.28 reqwest::dns::resolve::Resolve iroh-relay/src/dns.rs:450:1
reqwest 0.12.28 reqwest::error::Error iroh/src/address_lookup/pkarr.rs:106:9
rustls 0.23.36 rustls::client::client_conn::ClientConfig iroh-relay/src/client.rs:479:1
rustls 0.23.36 rustls::crypto::signer::CertifiedKey iroh-relay/src/server/resolver.rs:28:1
rustls 0.23.36 rustls::server::server_conn::ResolvesServerCert iroh-relay/src/server/resolver.rs:77:1
rustls 0.23.36 rustls::server::server_conn::ServerConfig iroh-relay/src/server.rs:174:5
rustls_pki_types 1.13.3 rustls_pki_types::CertificateDer iroh-relay/src/server.rs:231:9
signature 3.0.0-rc.6 signature::error::Error iroh-base/src/key.rs:206:1
simple_dns 0.9.3 simple_dns::simple_dns_error::SimpleDnsError iroh-relay/src/endpoint_info.rs:62:9
smallvec 1.15.1 smallvec::SmallVec iroh/src/socket/remote_map/remote_state.rs:1469:30
tokio 1.49.0 tokio::runtime::task::error::JoinError iroh-relay/src/server.rs:291:1
tokio 1.49.0 tokio::sync::watch::error::RecvError iroh-relay/src/quic.rs:227:1
tokio 1.49.0 tokio::time::error::Elapsed iroh-relay/src/client.rs:107:9
tokio_rustls_acme 0.9.0 tokio_rustls_acme::state::AcmeState iroh-relay/src/server.rs:226:9
tokio_util 0.7.18 tokio_util::task::abort_on_drop::AbortOnDropHandle iroh-relay/src/server.rs:495:5
tokio_websockets 0.12.3 tokio_websockets::error::Error iroh-relay/src/client.rs:49:1
z32 1.3.0 z32::Z32Error iroh-relay/src/endpoint_info.rs:73:9

Metadata

Metadata

Assignees

Labels

APItrackingan overview issue that tracks completion of a project

Type

Projects

Status

👍 Ready

Relationships

None yet

Development

No branches or pull requests

Issue actions