Skip to content

Commit 35598b4

Browse files
committed
De-export net::*. Part of #3583.
1 parent 53906bb commit 35598b4

File tree

5 files changed

+46
-91
lines changed

5 files changed

+46
-91
lines changed

src/libstd/net.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
//! Top-level module for network-related functionality
22
3-
use tcp = net_tcp;
4-
export tcp;
5-
6-
use ip = net_ip;
7-
export ip;
8-
9-
use url = net_url;
10-
export url;
3+
pub use tcp = net_tcp;
4+
pub use ip = net_ip;
5+
pub use url = net_url;

src/libstd/net_ip.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,8 @@ use get_data_for_req = uv::ll::get_data_for_req;
2020
use ll = uv::ll;
2121
use comm = core::comm;
2222

23-
export IpAddr, parse_addr_err;
24-
export format_addr;
25-
export v4, v6;
26-
export get_addr;
27-
export Ipv4, Ipv6;
28-
2923
/// An IP address
30-
enum IpAddr {
24+
pub enum IpAddr {
3125
/// An IPv4 address
3226
Ipv4(sockaddr_in),
3327
Ipv6(sockaddr_in6)
@@ -45,7 +39,7 @@ type ParseAddrErr = {
4539
*
4640
* * ip - a `std::net::ip::ip_addr`
4741
*/
48-
fn format_addr(ip: &IpAddr) -> ~str {
42+
pub fn format_addr(ip: &IpAddr) -> ~str {
4943
match *ip {
5044
Ipv4(ref addr) => unsafe {
5145
let result = uv_ip4_name(addr);
@@ -83,7 +77,7 @@ enum IpGetAddrErr {
8377
* a vector of `ip_addr` results, in the case of success, or an error
8478
* object in the case of failure
8579
*/
86-
fn get_addr(node: &str, iotask: iotask)
80+
pub fn get_addr(node: &str, iotask: iotask)
8781
-> result::Result<~[IpAddr], IpGetAddrErr> {
8882
do core::comm::listen |output_ch| {
8983
do str::as_buf(node) |node_ptr, len| unsafe {
@@ -116,8 +110,7 @@ fn get_addr(node: &str, iotask: iotask)
116110
}
117111
}
118112

119-
mod v4 {
120-
#[legacy_exports];
113+
pub mod v4 {
121114
/**
122115
* Convert a str to `ip_addr`
123116
*
@@ -133,17 +126,17 @@ mod v4 {
133126
*
134127
* * an `ip_addr` of the `ipv4` variant
135128
*/
136-
fn parse_addr(ip: &str) -> IpAddr {
129+
pub fn parse_addr(ip: &str) -> IpAddr {
137130
match try_parse_addr(ip) {
138131
result::Ok(copy addr) => addr,
139132
result::Err(ref err_data) => fail err_data.err_msg
140133
}
141134
}
142135
// the simple, old style numberic representation of
143136
// ipv4
144-
type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 };
137+
pub type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 };
145138

146-
trait AsUnsafeU32 {
139+
pub trait AsUnsafeU32 {
147140
unsafe fn as_u32() -> u32;
148141
}
149142

@@ -153,7 +146,7 @@ mod v4 {
153146
*((ptr::addr_of(&self)) as *u32)
154147
}
155148
}
156-
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
149+
pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
157150
let parts = vec::map(str::split_char(ip, '.'), |s| {
158151
match uint::from_str(*s) {
159152
Some(n) if n <= 255 => n,
@@ -171,7 +164,7 @@ mod v4 {
171164
c: parts[2] as u8, d: parts[3] as u8})
172165
}
173166
}
174-
fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
167+
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
175168
unsafe {
176169
let INADDR_NONE = ll::get_INADDR_NONE();
177170
let ip_rep_result = parse_to_ipv4_rep(ip);
@@ -203,8 +196,7 @@ mod v4 {
203196
}
204197
}
205198
}
206-
mod v6 {
207-
#[legacy_exports];
199+
pub mod v6 {
208200
/**
209201
* Convert a str to `ip_addr`
210202
*
@@ -220,13 +212,13 @@ mod v6 {
220212
*
221213
* * an `ip_addr` of the `ipv6` variant
222214
*/
223-
fn parse_addr(ip: &str) -> IpAddr {
215+
pub fn parse_addr(ip: &str) -> IpAddr {
224216
match try_parse_addr(ip) {
225217
result::Ok(copy addr) => addr,
226218
result::Err(copy err_data) => fail err_data.err_msg
227219
}
228220
}
229-
fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
221+
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
230222
unsafe {
231223
// need to figure out how to establish a parse failure..
232224
let new_addr = uv_ip6_addr(str::from_slice(ip), 22);
@@ -251,7 +243,7 @@ type GetAddrData = {
251243
};
252244

253245
extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
254-
res: *addrinfo) unsafe {
246+
res: *addrinfo) unsafe {
255247
log(debug, ~"in get_addr_cb");
256248
let handle_data = get_data_for_req(handle) as
257249
*GetAddrData;
@@ -311,7 +303,6 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
311303

312304
#[cfg(test)]
313305
mod test {
314-
#[legacy_exports];
315306
#[test]
316307
fn test_ip_ipv4_parse_and_format_ip() {
317308
let localhost_str = ~"127.0.0.1";

src/libstd/net_tcp.rs

+17-35
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,8 @@ use libc::size_t;
1111
use io::{Reader, ReaderUtil, Writer};
1212
use comm = core::comm;
1313

14-
// tcp interfaces
15-
export TcpSocket;
16-
// buffered socket
17-
export TcpSocketBuf, socket_buf;
18-
// errors
19-
export TcpErrData, TcpConnectErrData;
20-
// operations on a tcp_socket
21-
export write, write_future, read_start, read_stop;
22-
// tcp server stuff
23-
export listen, accept;
24-
// tcp client stuff
25-
export connect;
26-
2714
#[nolink]
2815
extern mod rustrt {
29-
#[legacy_exports];
3016
fn rust_uv_current_kernel_malloc(size: libc::c_uint) -> *libc::c_void;
3117
fn rust_uv_current_kernel_free(mem: *libc::c_void);
3218
fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
@@ -48,7 +34,7 @@ struct TcpSocket {
4834
}
4935
}
5036

51-
fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
37+
pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
5238
TcpSocket {
5339
socket_data: socket_data
5440
}
@@ -64,14 +50,14 @@ struct TcpSocketBuf {
6450
data: @TcpBufferedSocketData,
6551
}
6652

67-
fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
53+
pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
6854
TcpSocketBuf {
6955
data: data
7056
}
7157
}
7258

7359
/// Contains raw, string-based, error information returned from libuv
74-
type TcpErrData = {
60+
pub type TcpErrData = {
7561
err_name: ~str,
7662
err_msg: ~str
7763
};
@@ -103,7 +89,7 @@ enum TcpListenErrData {
10389
AccessDenied
10490
}
10591
/// Details returned as part of a `result::err` result from `tcp::connect`
106-
enum TcpConnectErrData {
92+
pub enum TcpConnectErrData {
10793
/**
10894
* Some unplanned-for error. The first and second fields correspond
10995
* to libuv's `err_name` and `err_msg` fields, respectively.
@@ -129,7 +115,7 @@ enum TcpConnectErrData {
129115
* the remote host. In the event of failure, a
130116
* `net::tcp::tcp_connect_err_data` instance will be returned
131117
*/
132-
fn connect(input_ip: ip::IpAddr, port: uint,
118+
pub fn connect(input_ip: ip::IpAddr, port: uint,
133119
iotask: IoTask)
134120
-> result::Result<TcpSocket, TcpConnectErrData> unsafe {
135121
let result_po = core::comm::Port::<ConnAttempt>();
@@ -262,7 +248,7 @@ fn connect(input_ip: ip::IpAddr, port: uint,
262248
* A `result` object with a `nil` value as the `ok` variant, or a
263249
* `tcp_err_data` value as the `err` variant
264250
*/
265-
fn write(sock: &TcpSocket, raw_write_data: ~[u8])
251+
pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
266252
-> result::Result<(), TcpErrData> unsafe {
267253
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
268254
write_common_impl(socket_data_ptr, raw_write_data)
@@ -299,7 +285,7 @@ fn write(sock: &TcpSocket, raw_write_data: ~[u8])
299285
* `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data`
300286
* value as the `err` variant
301287
*/
302-
fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
288+
pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
303289
-> future::Future<result::Result<(), TcpErrData>> unsafe {
304290
let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
305291
do future_spawn {
@@ -323,7 +309,7 @@ fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
323309
* optionally, loop on) from until `read_stop` is called, or a
324310
* `tcp_err_data` record
325311
*/
326-
fn read_start(sock: &TcpSocket)
312+
pub fn read_start(sock: &TcpSocket)
327313
-> result::Result<comm::Port<
328314
result::Result<~[u8], TcpErrData>>, TcpErrData> unsafe {
329315
let socket_data = ptr::addr_of(&(*(sock.socket_data)));
@@ -337,7 +323,7 @@ fn read_start(sock: &TcpSocket)
337323
*
338324
* * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
339325
*/
340-
fn read_stop(sock: &TcpSocket,
326+
pub fn read_stop(sock: &TcpSocket,
341327
+read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
342328
result::Result<(), TcpErrData> unsafe {
343329
log(debug, fmt!("taking the read_port out of commission %?", read_port));
@@ -472,7 +458,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
472458
* this function will return a `net::tcp::tcp_err_data` record
473459
* as the `err` variant of a `result`.
474460
*/
475-
fn accept(new_conn: TcpNewConnection)
461+
pub fn accept(new_conn: TcpNewConnection)
476462
-> result::Result<TcpSocket, TcpErrData> unsafe {
477463

478464
match new_conn{
@@ -570,7 +556,7 @@ fn accept(new_conn: TcpNewConnection)
570556
* successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
571557
* of listen exiting because of an error
572558
*/
573-
fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
559+
pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
574560
iotask: IoTask,
575561
+on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
576562
+new_connect_cb: fn~(TcpNewConnection,
@@ -728,17 +714,17 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
728714
*
729715
* A buffered wrapper that you can cast as an `io::reader` or `io::writer`
730716
*/
731-
fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
717+
pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
732718
TcpSocketBuf(@{ sock: move sock, mut buf: ~[] })
733719
}
734720

735721
/// Convenience methods extending `net::tcp::tcp_socket`
736722
impl TcpSocket {
737-
fn read_start() -> result::Result<comm::Port<
723+
pub fn read_start() -> result::Result<comm::Port<
738724
result::Result<~[u8], TcpErrData>>, TcpErrData> {
739725
read_start(&self)
740726
}
741-
fn read_stop(read_port:
727+
pub fn read_stop(read_port:
742728
comm::Port<result::Result<~[u8], TcpErrData>>) ->
743729
result::Result<(), TcpErrData> {
744730
read_stop(&self, move read_port)
@@ -751,11 +737,11 @@ impl TcpSocket {
751737
future::Future<result::Result<~[u8], TcpErrData>> {
752738
read_future(&self, timeout_msecs)
753739
}
754-
fn write(raw_write_data: ~[u8])
740+
pub fn write(raw_write_data: ~[u8])
755741
-> result::Result<(), TcpErrData> {
756742
write(&self, raw_write_data)
757743
}
758-
fn write_future(raw_write_data: ~[u8])
744+
pub fn write_future(raw_write_data: ~[u8])
759745
-> future::Future<result::Result<(), TcpErrData>> {
760746
write_future(&self, raw_write_data)
761747
}
@@ -816,7 +802,7 @@ impl TcpSocketBuf: io::Reader {
816802

817803
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
818804
impl TcpSocketBuf: io::Writer {
819-
fn write(data: &[const u8]) unsafe {
805+
pub fn write(data: &[const u8]) unsafe {
820806
let socket_data_ptr =
821807
ptr::addr_of(&(*((*(self.data)).sock).socket_data));
822808
let w_result = write_common_impl(socket_data_ptr,
@@ -1224,16 +1210,13 @@ type TcpBufferedSocketData = {
12241210

12251211
//#[cfg(test)]
12261212
mod test {
1227-
#[legacy_exports];
12281213
// FIXME don't run on fbsd or linux 32 bit (#2064)
12291214
#[cfg(target_os="win32")]
12301215
#[cfg(target_os="darwin")]
12311216
#[cfg(target_os="linux")]
12321217
mod tcp_ipv4_server_and_client_test {
1233-
#[legacy_exports];
12341218
#[cfg(target_arch="x86_64")]
12351219
mod impl64 {
1236-
#[legacy_exports];
12371220
#[test]
12381221
fn test_gl_tcp_server_and_client_ipv4() unsafe {
12391222
impl_gl_tcp_ipv4_server_and_client();
@@ -1258,7 +1241,6 @@ mod test {
12581241
}
12591242
#[cfg(target_arch="x86")]
12601243
mod impl32 {
1261-
#[legacy_exports];
12621244
#[test]
12631245
#[ignore(cfg(target_os = "linux"))]
12641246
fn test_gl_tcp_server_and_client_ipv4() unsafe {

0 commit comments

Comments
 (0)