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

General rework of the library #28

Merged
merged 3 commits into from Mar 5, 2018
Merged

General rework of the library #28

merged 3 commits into from Mar 5, 2018

Conversation

tomaka
Copy link
Member

@tomaka tomaka commented Dec 14, 2017

Based over #27

Right now if you want to examine the content of the Multiaddr, you have to call as_bytes() and examine bytes one by one and making the assumptions that they are going to be in a certain format.

This PR does many minor changes to the library, and most notably adds the AddrComponent type which represents one segment of a multiaddr in a strongly-typed fashion. The components can be enumerated with Multiaddr::iter(). Because of this large change, parsing has also been reworked.

@tomaka
Copy link
Member Author

tomaka commented Mar 5, 2018

This PR is an upstream of the local changes we've been making as part of https://github.com/libp2p/rust-libp2p/tree/master/rust-multiaddr

All these changes have already been reviewed. If nobody expresses opposition, I will merge in a few days.

Copy link
Member

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

one comment, other than lgtm

src/protocol.rs Outdated

use {Result, Error};

///! # Protocol
///! # ProtocolId
Copy link
Member

Choose a reason for hiding this comment

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

why this rename?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean this comment in particular, or the whole enum?

Copy link
Member

Choose a reason for hiding this comment

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

I meant the whole enum

Copy link
Member Author

Choose a reason for hiding this comment

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

That's subjective, but I think ProtocolId makes it clearer it is not a whole protocol definition for example.
I admit that in practice it's because in my first draft AddrComponent was named Protocol.

If you don't like it, I will change it back. I don't have a strong opinion.

Copy link
Member

Choose a reason for hiding this comment

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

lets use Protocol as it better matches what the go library is doing: https://github.com/multiformats/go-multiaddr/blob/master/protocols.go

@tomaka tomaka merged commit fa1a700 into multiformats:master Mar 5, 2018
@tomaka tomaka deleted the rework branch March 5, 2018 18:33
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.

None yet

2 participants