multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
86 stars 45 forks source link

Make decapsulate return an error if the protocol is not found #15

Closed progval closed 3 years ago

progval commented 7 years ago

The doc of decapsulate currently reads: “Returns the original if the passed in address is not found”.

Could you change the behavior of decapsulate to return an error of the protocol is not found? This way we have a way to know the protocol was not in the multiaddr. Additionally, it forces users of decapsulate to explicitly handle this case when calling it.

dignifiedquire commented 7 years ago

Sounds good.

deg4uss3r commented 6 years ago

Old issue but I might be able to help here, if this hasn’t been handled yet. :)

dignifiedquire commented 6 years ago

@deg4uss3r I don't think this has been handled yet, but you might want to look at #25 first which changes a lot of things around

deg4uss3r commented 6 years ago

Cool! I’ll hold off until that’s merged in.

ntninja commented 6 years ago

If this is wanted I can easily add change the final Ok(self.clone()) line in the decapsulate method of my PR to Err(…). I only thought that it may break backcompat, so I didn't do that yet.

mxinden commented 3 years ago

Closing here since decapsule has been removed in https://github.com/multiformats/rust-multiaddr/pull/40 in favor of basic iteration. Please speak up in case you would like to continue the discussion.