-
Notifications
You must be signed in to change notification settings - Fork 171
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
refactor!: improve reexport structure #3023
Conversation
iroh-base/src/lib.rs
Outdated
QuicConfig as RelayQuicConfig, RelayMap, RelayNode, DEFAULT_RELAY_QUIC_PORT, DEFAULT_STUN_PORT, | ||
}; | ||
#[cfg(any(feature = "relay", feature = "key"))] | ||
#[cfg_attr(iroh_docsrs, doc(cfg(any(feature = "relay", feature = "key"))))] |
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.
You should try this out, but I think if you reexport something from a module that has the #[cfg_attr(iroh_docsrs, doc(cfg(any(feature = "relay", feature = "key"))))]
thing, all reexports will also have the proper tags in the docs.
So you could simplify this by just having this statement on the (non-pub) module.
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.
Ah, never mind. This is just iroh-base...
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.
Why do we need a const for the size of an ed key in the first place?
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.
Why do we need a const for the size of an ed key in the first place?
we can drop that probably, need to check
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.
Why do we need a const for the size of an ed key in the first place?
it is used in a few places, sorry
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.
Just write 32 or have a const per crate. It is not going to change.
iroh-base/src/lib.rs
Outdated
#[cfg(feature = "relay")] | ||
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "relay")))] | ||
pub use self::relay_map::{ | ||
QuicConfig as RelayQuicConfig, RelayMap, RelayNode, DEFAULT_RELAY_QUIC_PORT, DEFAULT_STUN_PORT, |
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.
Not sure I like having these constants at top level. It is probably very rare that somebody needs them, so having them hidden away in some public mod is not that bad.
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 didn't find a better way, this is only for iroh-base
though, in iroh
it is much cleaner now
iroh-base/src/lib.rs
Outdated
#[cfg(feature = "relay")] | ||
#[cfg_attr(iroh_docsrs, doc(cfg(feature = "relay")))] | ||
pub use self::relay_map::{ | ||
QuicConfig as RelayQuicConfig, RelayMap, RelayNode, DEFAULT_RELAY_QUIC_PORT, DEFAULT_STUN_PORT, |
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 really don't like renames because the compiler will now give users confusing errors. Can you just rename the relay_map::QuicConfig
to relay_map::RelayQuicConfig
for this?
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.
sure
iroh-dns-server/examples/convert.rs
Outdated
@@ -1,7 +1,7 @@ | |||
use std::str::FromStr; | |||
|
|||
use clap::Parser; | |||
use iroh::NodeId; | |||
use iroh::key::NodeId; |
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.
Oh, not sure I like this no longer bing on the top level.
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.
fixed
iroh/src/lib.rs
Outdated
}; | ||
pub use iroh_relay as relay; | ||
pub use endpoint::{Endpoint, RelayMode}; | ||
pub use iroh_base::{hash, key, node_addr, relay_map, ticket}; |
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.
- do we need
hash
? - I'd like to keep
NodeId
at least at the toplevel. - If we're removing
RelayUrl
from here then why keepRelayMode
? Yes it's used in the builder but if you want anything else then disabled or default you'll need a whole bunch more relay types anyway.
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.
because RelayMode is defined in iroh, not in base
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'd like to keep
NodeId
at least at the toplevel.
that's fair
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.
- do we need
hash
?
interesting question, we actually don't
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.
hash
is gone now
504f711
to
4de6e89
Compare
Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3023/docs/iroh/ Last updated: 2024-12-12T10:34:00Z |
6ae64b8
to
d034234
Compare
these are all over the place
49faded
to
24cddc7
Compare
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.
seems like a decent improvement
@@ -6,7 +6,7 @@ use std::{ | |||
time::{Duration, Instant}, | |||
}; | |||
|
|||
use iroh_base::key::NodeId; | |||
use iroh_base::NodeId; |
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 find it a little odd that the imports don't come from crate::NodeId
... but I don't think this is a problem. Probably rust-analzyer will keep inserting this anyway.
Description
Restructures both
iroh_base
andiroh
reexports and type placements, to simplify and clarify the overall structures.Breaking Changes
iroh-base
key
->iroh_base::NodeId
etchash
->iroh_base::Hash
etcnode_addr
->iroh_base::NodeAddr
relay_url
->iroh_base::RelayUrl
relay_map
-> useiroh_relay::relay_map
iroh
hash
->iroh_base
ticket
->iroh_base::ticket
)relay
-> removed, useiroh_relay
directly if neededkey
->NodeId
, etc top level nowendpoint::Bytes
removed usebytes::Bytes
endpoint::NodeAddr
, useiroh::NodeAddr
Notes & open questions
Change checklist