Skip to content

std facade #13

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ cache: cargo
script:
- cargo test --verbose
- cargo build --features serde
- cargo build --features std
- cargo test --features std
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ serde = { version = "^1", default-features = false, optional = true }
serde_test = "^1"

[features]
# Makes the library act as a facade to std::net types
std = []
# Deprecated. Does nothing.
i128 = []
42 changes: 26 additions & 16 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,43 @@
)]
#![no_std]
#![deny(
dead_code,
missing_docs,
unused_imports,
unused_must_use,
unused_parens,
unused_qualifications,
warnings,
dead_code,
missing_docs,
unused_imports,
unused_must_use,
unused_parens,
unused_qualifications,
warnings
)]
#![forbid(unsafe_code)]

#[cfg(feature = "std")]
extern crate std;

#[cfg(not(feature = "std"))]
use core::fmt;

#[cfg(not(feature = "std"))]
mod addr;
#[cfg(not(feature = "std"))]
mod ip;
#[cfg(not(feature = "std"))]
mod parser;

#[cfg(feature = "serde")]
#[cfg(all(not(feature = "std"), feature = "serde"))]
extern crate serde;
#[cfg(feature = "serde")]
#[cfg(all(not(feature = "std"), feature = "serde"))]
mod de;
#[cfg(feature = "serde")]
#[cfg(all(not(feature = "std"), feature = "serde"))]
mod ser;

#[cfg(not(feature = "std"))]
pub use addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
#[cfg(not(feature = "std"))]
pub use ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};

pub use addr::{ SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs };
pub use ip::{ IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope };
pub use parser::{ AddrParseError };
// Re-export std::net types when std is available
#[cfg(feature = "std")]
extern crate std;
// pub use std::net::Ipv6MulticastScope;
#[cfg(feature = "std")]
pub use std::net::{
IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs,
};