about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorGraydon Hoare <graydon@mozilla.com>2012-10-03 16:43:56 -0700
committerGraydon Hoare <graydon@mozilla.com>2012-10-03 17:01:32 -0700
commit35598b4595ec6b7ae4ea6c0244f775651366fe9e (patch)
tree29ca15318fba2226ad8735404eeab8bf4f53a053 /src/libstd
parent53906bb4fb9b2a99878fc6a5cc5cc174ffdea25c (diff)
downloadrust-35598b4595ec6b7ae4ea6c0244f775651366fe9e.tar.gz
rust-35598b4595ec6b7ae4ea6c0244f775651366fe9e.zip
De-export net::*. Part of #3583.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/net.rs11
-rw-r--r--src/libstd/net_ip.rs35
-rw-r--r--src/libstd/net_tcp.rs52
-rw-r--r--src/libstd/net_url.rs35
-rw-r--r--src/libstd/std.rc4
5 files changed, 46 insertions, 91 deletions
diff --git a/src/libstd/net.rs b/src/libstd/net.rs
index 8665ea2e9cf..76a5955c3e1 100644
--- a/src/libstd/net.rs
+++ b/src/libstd/net.rs
@@ -1,10 +1,5 @@
 //! Top-level module for network-related functionality
 
-use tcp = net_tcp;
-export tcp;
-
-use ip = net_ip;
-export ip;
-
-use url = net_url;
-export url;
\ No newline at end of file
+pub use tcp = net_tcp;
+pub use ip = net_ip;
+pub use url = net_url;
diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs
index 9aa29df4a62..2d9dd5bdf4e 100644
--- a/src/libstd/net_ip.rs
+++ b/src/libstd/net_ip.rs
@@ -20,14 +20,8 @@ use get_data_for_req = uv::ll::get_data_for_req;
 use ll = uv::ll;
 use comm = core::comm;
 
-export IpAddr, parse_addr_err;
-export format_addr;
-export v4, v6;
-export get_addr;
-export Ipv4, Ipv6;
-
 /// An IP address
-enum IpAddr {
+pub enum IpAddr {
     /// An IPv4 address
     Ipv4(sockaddr_in),
     Ipv6(sockaddr_in6)
@@ -45,7 +39,7 @@ type ParseAddrErr = {
  *
  * * ip - a `std::net::ip::ip_addr`
  */
-fn format_addr(ip: &IpAddr) -> ~str {
+pub fn format_addr(ip: &IpAddr) -> ~str {
     match *ip {
       Ipv4(ref addr) =>  unsafe {
         let result = uv_ip4_name(addr);
@@ -83,7 +77,7 @@ enum IpGetAddrErr {
  * a vector of `ip_addr` results, in the case of success, or an error
  * object in the case of failure
  */
-fn get_addr(node: &str, iotask: iotask)
+pub fn get_addr(node: &str, iotask: iotask)
         -> result::Result<~[IpAddr], IpGetAddrErr> {
     do core::comm::listen |output_ch| {
         do str::as_buf(node) |node_ptr, len| unsafe {
@@ -116,8 +110,7 @@ fn get_addr(node: &str, iotask: iotask)
     }
 }
 
-mod v4 {
-    #[legacy_exports];
+pub mod v4 {
     /**
      * Convert a str to `ip_addr`
      *
@@ -133,7 +126,7 @@ mod v4 {
      *
      * * an `ip_addr` of the `ipv4` variant
      */
-    fn parse_addr(ip: &str) -> IpAddr {
+    pub fn parse_addr(ip: &str) -> IpAddr {
         match try_parse_addr(ip) {
           result::Ok(copy addr) => addr,
           result::Err(ref err_data) => fail err_data.err_msg
@@ -141,9 +134,9 @@ mod v4 {
     }
     // the simple, old style numberic representation of
     // ipv4
-    type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 };
+    pub type Ipv4Rep = { a: u8, b: u8, c: u8, d:u8 };
 
-    trait AsUnsafeU32 {
+    pub trait AsUnsafeU32 {
         unsafe fn as_u32() -> u32;
     }
 
@@ -153,7 +146,7 @@ mod v4 {
             *((ptr::addr_of(&self)) as *u32)
         }
     }
-    fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
+    pub fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
         let parts = vec::map(str::split_char(ip, '.'), |s| {
             match uint::from_str(*s) {
               Some(n) if n <= 255 => n,
@@ -171,7 +164,7 @@ mod v4 {
                         c: parts[2] as u8, d: parts[3] as u8})
         }
     }
-    fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
+    pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
         unsafe {
             let INADDR_NONE = ll::get_INADDR_NONE();
             let ip_rep_result = parse_to_ipv4_rep(ip);
@@ -203,8 +196,7 @@ mod v4 {
         }
     }
 }
-mod v6 {
-    #[legacy_exports];
+pub mod v6 {
     /**
      * Convert a str to `ip_addr`
      *
@@ -220,13 +212,13 @@ mod v6 {
      *
      * * an `ip_addr` of the `ipv6` variant
      */
-    fn parse_addr(ip: &str) -> IpAddr {
+    pub fn parse_addr(ip: &str) -> IpAddr {
         match try_parse_addr(ip) {
           result::Ok(copy addr) => addr,
           result::Err(copy err_data) => fail err_data.err_msg
         }
     }
-    fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
+    pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
         unsafe {
             // need to figure out how to establish a parse failure..
             let new_addr = uv_ip6_addr(str::from_slice(ip), 22);
@@ -251,7 +243,7 @@ type GetAddrData = {
 };
 
 extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
-                     res: *addrinfo) unsafe {
+                      res: *addrinfo) unsafe {
     log(debug, ~"in get_addr_cb");
     let handle_data = get_data_for_req(handle) as
         *GetAddrData;
@@ -311,7 +303,6 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t, status: libc::c_int,
 
 #[cfg(test)]
 mod test {
-    #[legacy_exports];
     #[test]
     fn test_ip_ipv4_parse_and_format_ip() {
         let localhost_str = ~"127.0.0.1";
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs
index be38f16aff7..546231da633 100644
--- a/src/libstd/net_tcp.rs
+++ b/src/libstd/net_tcp.rs
@@ -11,22 +11,8 @@ use libc::size_t;
 use io::{Reader, ReaderUtil, Writer};
 use comm = core::comm;
 
-// tcp interfaces
-export TcpSocket;
-// buffered socket
-export TcpSocketBuf, socket_buf;
-// errors
-export TcpErrData, TcpConnectErrData;
-// operations on a tcp_socket
-export write, write_future, read_start, read_stop;
-// tcp server stuff
-export listen, accept;
-// tcp client stuff
-export connect;
-
 #[nolink]
 extern mod rustrt {
-    #[legacy_exports];
     fn rust_uv_current_kernel_malloc(size: libc::c_uint) -> *libc::c_void;
     fn rust_uv_current_kernel_free(mem: *libc::c_void);
     fn rust_uv_helper_uv_tcp_t_size() -> libc::c_uint;
@@ -48,7 +34,7 @@ struct TcpSocket {
   }
 }
 
-fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
+pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
     TcpSocket {
         socket_data: socket_data
     }
@@ -64,14 +50,14 @@ struct TcpSocketBuf {
     data: @TcpBufferedSocketData,
 }
 
-fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
+pub fn TcpSocketBuf(data: @TcpBufferedSocketData) -> TcpSocketBuf {
     TcpSocketBuf {
         data: data
     }
 }
 
 /// Contains raw, string-based, error information returned from libuv
-type TcpErrData = {
+pub type TcpErrData = {
     err_name: ~str,
     err_msg: ~str
 };
@@ -103,7 +89,7 @@ enum TcpListenErrData {
     AccessDenied
 }
 /// Details returned as part of a `result::err` result from `tcp::connect`
-enum TcpConnectErrData {
+pub enum TcpConnectErrData {
     /**
      * Some unplanned-for error. The first and second fields correspond
      * to libuv's `err_name` and `err_msg` fields, respectively.
@@ -129,7 +115,7 @@ enum TcpConnectErrData {
  * the remote host. In the event of failure, a
  * `net::tcp::tcp_connect_err_data` instance will be returned
  */
-fn connect(input_ip: ip::IpAddr, port: uint,
+pub fn connect(input_ip: ip::IpAddr, port: uint,
            iotask: IoTask)
     -> result::Result<TcpSocket, TcpConnectErrData> unsafe {
     let result_po = core::comm::Port::<ConnAttempt>();
@@ -262,7 +248,7 @@ fn connect(input_ip: ip::IpAddr, port: uint,
  * A `result` object with a `nil` value as the `ok` variant, or a
  * `tcp_err_data` value as the `err` variant
  */
-fn write(sock: &TcpSocket, raw_write_data: ~[u8])
+pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
     -> result::Result<(), TcpErrData> unsafe {
     let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
     write_common_impl(socket_data_ptr, raw_write_data)
@@ -299,7 +285,7 @@ fn write(sock: &TcpSocket, raw_write_data: ~[u8])
  * `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data`
  * value as the `err` variant
  */
-fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
+pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
     -> future::Future<result::Result<(), TcpErrData>> unsafe {
     let socket_data_ptr = ptr::addr_of(&(*(sock.socket_data)));
     do future_spawn {
@@ -323,7 +309,7 @@ fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
  * optionally, loop on) from until `read_stop` is called, or a
  * `tcp_err_data` record
  */
-fn read_start(sock: &TcpSocket)
+pub fn read_start(sock: &TcpSocket)
     -> result::Result<comm::Port<
         result::Result<~[u8], TcpErrData>>, TcpErrData> unsafe {
     let socket_data = ptr::addr_of(&(*(sock.socket_data)));
@@ -337,7 +323,7 @@ fn read_start(sock: &TcpSocket)
  *
  * * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
  */
-fn read_stop(sock: &TcpSocket,
+pub fn read_stop(sock: &TcpSocket,
              +read_port: comm::Port<result::Result<~[u8], TcpErrData>>) ->
     result::Result<(), TcpErrData> unsafe {
     log(debug, fmt!("taking the read_port out of commission %?", read_port));
@@ -472,7 +458,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
  * this function will return a `net::tcp::tcp_err_data` record
  * as the `err` variant of a `result`.
  */
-fn accept(new_conn: TcpNewConnection)
+pub fn accept(new_conn: TcpNewConnection)
     -> result::Result<TcpSocket, TcpErrData> unsafe {
 
     match new_conn{
@@ -570,7 +556,7 @@ fn accept(new_conn: TcpNewConnection)
  * successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
  * of listen exiting because of an error
  */
-fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
+pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
           iotask: IoTask,
           +on_establish_cb: fn~(comm::Chan<Option<TcpErrData>>),
           +new_connect_cb: fn~(TcpNewConnection,
@@ -728,17 +714,17 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
  *
  * A buffered wrapper that you can cast as an `io::reader` or `io::writer`
  */
-fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
+pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
     TcpSocketBuf(@{ sock: move sock, mut buf: ~[] })
 }
 
 /// Convenience methods extending `net::tcp::tcp_socket`
 impl TcpSocket {
-    fn read_start() -> result::Result<comm::Port<
+    pub fn read_start() -> result::Result<comm::Port<
         result::Result<~[u8], TcpErrData>>, TcpErrData> {
         read_start(&self)
     }
-    fn read_stop(read_port:
+    pub fn read_stop(read_port:
                  comm::Port<result::Result<~[u8], TcpErrData>>) ->
         result::Result<(), TcpErrData> {
         read_stop(&self, move read_port)
@@ -751,11 +737,11 @@ impl TcpSocket {
         future::Future<result::Result<~[u8], TcpErrData>> {
         read_future(&self, timeout_msecs)
     }
-    fn write(raw_write_data: ~[u8])
+    pub fn write(raw_write_data: ~[u8])
         -> result::Result<(), TcpErrData> {
         write(&self, raw_write_data)
     }
-    fn write_future(raw_write_data: ~[u8])
+    pub fn write_future(raw_write_data: ~[u8])
         -> future::Future<result::Result<(), TcpErrData>> {
         write_future(&self, raw_write_data)
     }
@@ -816,7 +802,7 @@ impl TcpSocketBuf: io::Reader {
 
 /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
 impl TcpSocketBuf: io::Writer {
-    fn write(data: &[const u8]) unsafe {
+    pub fn write(data: &[const u8]) unsafe {
         let socket_data_ptr =
             ptr::addr_of(&(*((*(self.data)).sock).socket_data));
         let w_result = write_common_impl(socket_data_ptr,
@@ -1224,16 +1210,13 @@ type TcpBufferedSocketData = {
 
 //#[cfg(test)]
 mod test {
-    #[legacy_exports];
     // FIXME don't run on fbsd or linux 32 bit (#2064)
     #[cfg(target_os="win32")]
     #[cfg(target_os="darwin")]
     #[cfg(target_os="linux")]
     mod tcp_ipv4_server_and_client_test {
-        #[legacy_exports];
         #[cfg(target_arch="x86_64")]
         mod impl64 {
-            #[legacy_exports];
             #[test]
             fn test_gl_tcp_server_and_client_ipv4() unsafe {
                 impl_gl_tcp_ipv4_server_and_client();
@@ -1258,7 +1241,6 @@ mod test {
         }
         #[cfg(target_arch="x86")]
         mod impl32 {
-            #[legacy_exports];
             #[test]
             #[ignore(cfg(target_os = "linux"))]
             fn test_gl_tcp_server_and_client_ipv4() unsafe {
diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs
index 6dca075405b..40c9f96f5e8 100644
--- a/src/libstd/net_url.rs
+++ b/src/libstd/net_url.rs
@@ -10,15 +10,6 @@ use result::{Err, Ok};
 use to_str::ToStr;
 use to_bytes::IterBytes;
 
-export Url, Query;
-export from_str, to_str;
-export get_scheme;
-export query_to_str;
-
-export encode, decode;
-export encode_component, decode_component;
-export encode_form_urlencoded, decode_form_urlencoded;
-
 struct Url {
     scheme: ~str,
     user: Option<UserInfo>,
@@ -34,9 +25,9 @@ type UserInfo = {
     pass: Option<~str>
 };
 
-type Query = ~[(~str, ~str)];
+pub type Query = ~[(~str, ~str)];
 
-fn Url(scheme: ~str, +user: Option<UserInfo>, +host: ~str,
+pub fn Url(scheme: ~str, +user: Option<UserInfo>, +host: ~str,
        +port: Option<~str>, +path: ~str, +query: Query,
        +fragment: Option<~str>) -> Url {
     Url { scheme: move scheme, user: move user, host: move host,
@@ -93,7 +84,7 @@ fn encode_inner(s: &str, full_url: bool) -> ~str {
  *
  * This function is compliant with RFC 3986.
  */
-fn encode(s: &str) -> ~str {
+pub fn encode(s: &str) -> ~str {
     encode_inner(s, true)
 }
 
@@ -103,7 +94,7 @@ fn encode(s: &str) -> ~str {
  *
  * This function is compliant with RFC 3986.
  */
-fn encode_component(s: &str) -> ~str {
+pub fn encode_component(s: &str) -> ~str {
     encode_inner(s, false)
 }
 
@@ -150,14 +141,14 @@ fn decode_inner(s: &str, full_url: bool) -> ~str {
  *
  * This will only decode escape sequences generated by encode_uri.
  */
-fn decode(s: &str) -> ~str {
+pub fn decode(s: &str) -> ~str {
     decode_inner(s, true)
 }
 
 /**
  * Decode a string encoded with percent encoding.
  */
-fn decode_component(s: &str) -> ~str {
+pub fn decode_component(s: &str) -> ~str {
     decode_inner(s, false)
 }
 
@@ -183,7 +174,7 @@ fn encode_plus(s: &str) -> ~str {
 /**
  * Encode a hashmap to the 'application/x-www-form-urlencoded' media type.
  */
-fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
+pub fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
     let mut out = ~"";
     let mut first = true;
 
@@ -209,7 +200,7 @@ fn encode_form_urlencoded(m: HashMap<~str, @DVec<@~str>>) -> ~str {
  * Decode a string encoded with the 'application/x-www-form-urlencoded' media
  * type into a hashmap.
  */
-fn decode_form_urlencoded(s: ~[u8]) ->
+pub fn decode_form_urlencoded(s: ~[u8]) ->
     map::HashMap<~str, @dvec::DVec<@~str>> {
     do io::with_bytes_reader(s) |rdr| {
         let m = HashMap();
@@ -334,7 +325,7 @@ fn query_from_str(rawquery: &str) -> Query {
     return query;
 }
 
-fn query_to_str(query: Query) -> ~str {
+pub fn query_to_str(query: Query) -> ~str {
     let mut strvec = ~[];
     for query.each |kv| {
         let (k, v) = copy *kv;
@@ -344,7 +335,7 @@ fn query_to_str(query: Query) -> ~str {
 }
 
 // returns the scheme and the rest of the url, or a parsing error
-fn get_scheme(rawurl: &str) -> result::Result<(~str, ~str), @~str> {
+pub fn get_scheme(rawurl: &str) -> result::Result<(~str, ~str), @~str> {
     for str::each_chari(rawurl) |i,c| {
         match c {
           'A' .. 'Z' | 'a' .. 'z' => loop,
@@ -623,7 +614,7 @@ fn get_query_fragment(rawurl: &str) ->
  *
  */
 
-fn from_str(rawurl: &str) -> result::Result<Url, ~str> {
+pub fn from_str(rawurl: &str) -> result::Result<Url, ~str> {
     // scheme
     let mut schm = get_scheme(rawurl);
     if result::is_err(&schm) {
@@ -681,7 +672,7 @@ impl Url : FromStr {
  * result in just "http://somehost.com".
  *
  */
-fn to_str(url: Url) -> ~str {
+pub fn to_str(url: Url) -> ~str {
     let user = if url.user.is_some() {
       userinfo_to_str(option::unwrap(copy url.user))
     } else {
@@ -713,7 +704,7 @@ fn to_str(url: Url) -> ~str {
 }
 
 impl Url: to_str::ToStr {
-    fn to_str() -> ~str {
+    pub fn to_str() -> ~str {
         to_str(self)
     }
 }
diff --git a/src/libstd/std.rc b/src/libstd/std.rc
index 683ea589b91..6a5658d24eb 100644
--- a/src/libstd/std.rc
+++ b/src/libstd/std.rc
@@ -44,13 +44,9 @@ export cell;
 
 // General io and system-services modules
 
-#[legacy_exports]
 mod net;
-#[legacy_exports]
 mod net_ip;
-#[legacy_exports]
 mod net_tcp;
-#[legacy_exports]
 mod net_url;
 
 // libuv modules