std: import/export cleanup in net_tcp

This commit is contained in:
Jeff Olson 2012-05-27 09:49:33 -07:00 committed by Brian Anderson
parent 79e279ee12
commit 900e446015

View File

@ -7,8 +7,10 @@
import uv::iotask::iotask;
import comm::methods;
import future_spawn = future::spawn;
import future::future;
import result::{result,err,ok,extensions};
// FIXME: should be able to replace w/ result::{result, extensions};
import result::*;
import libc::size_t;
import str::extensions;
// data
export tcp_socket, tcp_conn_port, tcp_err_data;
@ -20,7 +22,7 @@
// tcp client stuff
export connect;
// helper methods
export conn_port_methods, sock_methods;
export methods;
#[nolink]
native mod rustrt {
@ -775,13 +777,14 @@ fn listen_for_conn(host_ip: ip::ip_addr, port: uint, backlog: uint,
}
}
}
mod methods {
#[doc="
Convenience methods extending `net::tcp::tcp_conn_port`
"]
impl conn_port_methods for tcp_conn_port {
fn recv() -> result::result<tcp_socket, tcp_err_data> { conn_recv(self) }
fn recv_spawn(+cb: fn~(result::result<tcp_socket,tcp_err_data>))
impl methods_tcp_conn_port for tcp_conn_port {
fn recv() -> result::result<tcp_socket, tcp_err_data> {
conn_recv(self) }
fn recv_spawn(cb: fn~(result::result<tcp_socket,tcp_err_data>))
{ conn_recv_spawn(self, cb); }
fn peek() -> bool { conn_peek(self) }
}
@ -789,7 +792,7 @@ fn peek() -> bool { conn_peek(self) }
#[doc="
Convenience methods extending `net::tcp::tcp_socket`
"]
impl sock_methods for tcp_socket {
impl methods_tcp_socket for tcp_socket {
fn read_start() -> result::result<comm::port<
result::result<[u8]/~, tcp_err_data>>, tcp_err_data> {
read_start(self)
@ -803,7 +806,7 @@ fn read(timeout_msecs: uint) ->
read(self, timeout_msecs)
}
fn read_future(timeout_msecs: uint) ->
future<result::result<[u8]/~, tcp_err_data>> {
future::future<result::result<[u8]/~, tcp_err_data>> {
read_future(self, timeout_msecs)
}
fn write(raw_write_data: [u8]/~)
@ -811,10 +814,11 @@ fn write(raw_write_data: [u8]/~)
write(self, raw_write_data)
}
fn write_future(raw_write_data: [u8]/~)
-> future<result::result<(), tcp_err_data>> {
-> future::future<result::result<(), tcp_err_data>> {
write_future(self, raw_write_data)
}
}
}
// INTERNAL API
// shared implementation for tcp::read
@ -1171,7 +1175,7 @@ fn to_tcp_err() -> tcp_err_data {
}
crust fn on_alloc_cb(handle: *libc::c_void,
++suggested_size: libc::size_t)
++suggested_size: size_t)
-> uv::ll::uv_buf_t unsafe {
log(debug, "tcp read on_alloc_cb!");
let char_ptr = uv::ll::malloc_buf_base_of(suggested_size);