Skip to content

Commit

Permalink
Merge pull request #33 from multiformats/feat/update-deps-and-release
Browse files Browse the repository at this point in the history
update deps and cut a release
  • Loading branch information
Stebalien authored Nov 29, 2018
2 parents 4e4fe1b + a3d1ef7 commit 9682623
Show file tree
Hide file tree
Showing 5 changed files with 255 additions and 230 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ keywords = ["multiaddr", "ipfs"]
license = "MIT"
name = "multiaddr"
readme = "README.md"
version = "0.3.0"
version = "0.3.1"

[dependencies]
byteorder = "~0.4"
cid = "~0.2"
integer-encoding = "~1.0.3"
byteorder = "1.0"
cid = "~0.3"
integer-encoding = "1.0.3"

[dev-dependencies]
data-encoding = "~1.1.2"
data-encoding = "2.0.0"
11 changes: 2 additions & 9 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{net, fmt, error, io, num, string};
use cid;
use byteorder;
use std::{error, fmt, io, net, num, string};

pub type Result<T> = ::std::result::Result<T, Error>;

Expand Down Expand Up @@ -35,7 +34,7 @@ impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::ParsingError(ref err) => Some(&**err),
_ => None
_ => None,
}
}
}
Expand All @@ -58,12 +57,6 @@ impl From<net::AddrParseError> for Error {
}
}

impl From<byteorder::Error> for Error {
fn from(err: byteorder::Error) -> Error {
Error::ParsingError(err.into())
}
}

impl From<num::ParseIntError> for Error {
fn from(err: num::ParseIntError) -> Error {
Error::ParsingError(err.into())
Expand Down
42 changes: 21 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ extern crate byteorder;
extern crate cid;
extern crate integer_encoding;

mod protocol;
mod errors;
mod protocol;

pub use errors::{Result, Error};
pub use protocol::{Protocol, ProtocolArgSize, AddrComponent};
pub use errors::{Error, Result};
pub use protocol::{AddrComponent, Protocol, ProtocolArgSize};

use std::fmt;
use std::iter::FromIterator;
use std::net::{SocketAddr, SocketAddrV4, SocketAddrV6, IpAddr, Ipv4Addr, Ipv6Addr};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use std::str::FromStr;

/// Representation of a Multiaddr.
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Multiaddr {

bytes.extend(new.to_bytes());

Ok(Multiaddr { bytes: bytes })
Ok(Multiaddr { bytes })
}

/// Adds an already-parsed address component to the end of this multiaddr.
Expand All @@ -135,9 +135,9 @@ impl Multiaddr {
///
#[inline]
pub fn append(&mut self, component: AddrComponent) {
component.write_bytes(&mut self.bytes).expect(
"writing to a Vec never fails",
)
component
.write_bytes(&mut self.bytes)
.expect("writing to a Vec never fails")
}

/// Remove the outermost address.
Expand Down Expand Up @@ -191,13 +191,15 @@ impl Multiaddr {
}

if !matches {
return Ok(Multiaddr { bytes: self.bytes.clone() });
return Ok(Multiaddr {
bytes: self.bytes.clone(),
});
}

let mut bytes = self.bytes.clone();
bytes.truncate(input_pos);

Ok(Multiaddr { bytes: bytes })
Ok(Multiaddr { bytes })
}

/// Returns the components of this multiaddress.
Expand Down Expand Up @@ -243,9 +245,8 @@ impl Multiaddr {
impl From<AddrComponent> for Multiaddr {
fn from(addr: AddrComponent) -> Multiaddr {
let mut out = Vec::new();
addr.write_bytes(&mut out).expect(
"writing to a Vec never fails",
);
addr.write_bytes(&mut out)
.expect("writing to a Vec never fails");
Multiaddr { bytes: out }
}
}
Expand All @@ -267,11 +268,10 @@ impl FromIterator<AddrComponent> for Multiaddr {
{
let mut bytes = Vec::new();
for cmp in iter {
cmp.write_bytes(&mut bytes).expect(
"writing to a Vec never fails",
);
cmp.write_bytes(&mut bytes)
.expect("writing to a Vec never fails");
}
Multiaddr { bytes: bytes }
Multiaddr { bytes }
}
}

Expand Down Expand Up @@ -300,12 +300,12 @@ impl FromStr for Multiaddr {
}
};

addr_component.write_bytes(&mut bytes).expect(
"writing to a Vec never fails",
);
addr_component
.write_bytes(&mut bytes)
.expect("writing to a Vec never fails");
}

Ok(Multiaddr { bytes: bytes })
Ok(Multiaddr { bytes })
}
}

Expand Down
Loading

0 comments on commit 9682623

Please sign in to comment.