-
Notifications
You must be signed in to change notification settings - Fork 89
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
modules: Create net module #820
base: main
Are you sure you want to change the base?
Conversation
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.
Cheers. So we're missing rune doctests, and the module has to be installed to be available. See where the module
function is used for other modules.
@udoprog how do I implement generating an IpAddr from a string, int, array of ints, etc., similar to the std IpAddr? ("127.0.0.1".parse())
(127, 0, 0, 1)
[127, 0, 0, 1] |
You add the relevant methods to perform the conversion. Like the |
/// An IP address, either IPv4 or IPv6. | ||
#[derive(Debug, Any)] | ||
#[rune(item = ::std::net)] | ||
pub struct IpAddr { | ||
inner: net::IpAddr, | ||
} |
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.
We need a way to create an IpAddr
. What is a preference: enum or constructors?
The std is IpAddr::V4(...)
or V6(...)
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.
The target is "Whatever Rust does" unless there is a good reason to deviate. So an Enum seems like the answer right now.
Make sure to add doc tests which exercises the constructors and pattern matching over the various variants to make sure they are installed!
Add a
net module
, initially with SocketAddr and IpAddr types and their respective methods. TCP and UDP will be implemented in the future.