|
13 | 13 | use core::prelude::*;
|
14 | 14 | use alloc::boxed::Box;
|
15 | 15 | use collections::string::String;
|
16 |
| -use collections::vec::Vec; |
17 |
| -use core::fmt; |
18 | 16 | use core::mem;
|
19 | 17 | use libc::c_int;
|
20 |
| -use libc; |
21 | 18 |
|
22 |
| -use c_str::CString; |
23 | 19 | use local::Local;
|
24 | 20 | use task::Task;
|
25 | 21 |
|
@@ -173,87 +169,15 @@ impl<'a> LocalIo<'a> {
|
173 | 169 | }
|
174 | 170 |
|
175 | 171 | pub trait IoFactory {
|
176 |
| - // networking |
177 |
| - fn tcp_connect(&mut self, addr: SocketAddr, |
178 |
| - timeout: Option<u64>) -> IoResult<Box<RtioTcpStream + Send>>; |
179 |
| - fn tcp_bind(&mut self, addr: SocketAddr) |
180 |
| - -> IoResult<Box<RtioTcpListener + Send>>; |
181 |
| - fn udp_bind(&mut self, addr: SocketAddr) |
182 |
| - -> IoResult<Box<RtioUdpSocket + Send>>; |
183 |
| - fn unix_bind(&mut self, path: &CString) |
184 |
| - -> IoResult<Box<RtioUnixListener + Send>>; |
185 |
| - fn unix_connect(&mut self, path: &CString, |
186 |
| - timeout: Option<u64>) -> IoResult<Box<RtioPipe + Send>>; |
187 |
| - fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>, |
188 |
| - hint: Option<AddrinfoHint>) |
189 |
| - -> IoResult<Vec<AddrinfoInfo>>; |
190 |
| - |
191 |
| - // misc |
192 | 172 | fn timer_init(&mut self) -> IoResult<Box<RtioTimer + Send>>;
|
193 | 173 | fn spawn(&mut self, cfg: ProcessConfig)
|
194 | 174 | -> IoResult<(Box<RtioProcess + Send>,
|
195 | 175 | Vec<Option<Box<RtioPipe + Send>>>)>;
|
196 | 176 | fn kill(&mut self, pid: libc::pid_t, signal: int) -> IoResult<()>;
|
197 |
| - fn pipe_open(&mut self, fd: c_int) -> IoResult<Box<RtioPipe + Send>>; |
198 | 177 | fn tty_open(&mut self, fd: c_int, readable: bool)
|
199 | 178 | -> IoResult<Box<RtioTTY + Send>>;
|
200 | 179 | }
|
201 | 180 |
|
202 |
| -pub trait RtioTcpListener : RtioSocket { |
203 |
| - fn listen(self: Box<Self>) -> IoResult<Box<RtioTcpAcceptor + Send>>; |
204 |
| -} |
205 |
| - |
206 |
| -pub trait RtioTcpAcceptor : RtioSocket { |
207 |
| - fn accept(&mut self) -> IoResult<Box<RtioTcpStream + Send>>; |
208 |
| - fn accept_simultaneously(&mut self) -> IoResult<()>; |
209 |
| - fn dont_accept_simultaneously(&mut self) -> IoResult<()>; |
210 |
| - fn set_timeout(&mut self, timeout: Option<u64>); |
211 |
| - fn clone(&self) -> Box<RtioTcpAcceptor + Send>; |
212 |
| - fn close_accept(&mut self) -> IoResult<()>; |
213 |
| -} |
214 |
| - |
215 |
| -pub trait RtioTcpStream : RtioSocket { |
216 |
| - fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>; |
217 |
| - fn write(&mut self, buf: &[u8]) -> IoResult<()>; |
218 |
| - fn peer_name(&mut self) -> IoResult<SocketAddr>; |
219 |
| - fn control_congestion(&mut self) -> IoResult<()>; |
220 |
| - fn nodelay(&mut self) -> IoResult<()>; |
221 |
| - fn keepalive(&mut self, delay_in_seconds: uint) -> IoResult<()>; |
222 |
| - fn letdie(&mut self) -> IoResult<()>; |
223 |
| - fn clone(&self) -> Box<RtioTcpStream + Send>; |
224 |
| - fn close_write(&mut self) -> IoResult<()>; |
225 |
| - fn close_read(&mut self) -> IoResult<()>; |
226 |
| - fn set_timeout(&mut self, timeout_ms: Option<u64>); |
227 |
| - fn set_read_timeout(&mut self, timeout_ms: Option<u64>); |
228 |
| - fn set_write_timeout(&mut self, timeout_ms: Option<u64>); |
229 |
| -} |
230 |
| - |
231 |
| -pub trait RtioSocket { |
232 |
| - fn socket_name(&mut self) -> IoResult<SocketAddr>; |
233 |
| -} |
234 |
| - |
235 |
| -pub trait RtioUdpSocket : RtioSocket { |
236 |
| - fn recv_from(&mut self, buf: &mut [u8]) -> IoResult<(uint, SocketAddr)>; |
237 |
| - fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()>; |
238 |
| - |
239 |
| - fn join_multicast(&mut self, multi: IpAddr) -> IoResult<()>; |
240 |
| - fn leave_multicast(&mut self, multi: IpAddr) -> IoResult<()>; |
241 |
| - |
242 |
| - fn loop_multicast_locally(&mut self) -> IoResult<()>; |
243 |
| - fn dont_loop_multicast_locally(&mut self) -> IoResult<()>; |
244 |
| - |
245 |
| - fn multicast_time_to_live(&mut self, ttl: int) -> IoResult<()>; |
246 |
| - fn time_to_live(&mut self, ttl: int) -> IoResult<()>; |
247 |
| - |
248 |
| - fn hear_broadcasts(&mut self) -> IoResult<()>; |
249 |
| - fn ignore_broadcasts(&mut self) -> IoResult<()>; |
250 |
| - |
251 |
| - fn clone(&self) -> Box<RtioUdpSocket + Send>; |
252 |
| - fn set_timeout(&mut self, timeout_ms: Option<u64>); |
253 |
| - fn set_read_timeout(&mut self, timeout_ms: Option<u64>); |
254 |
| - fn set_write_timeout(&mut self, timeout_ms: Option<u64>); |
255 |
| -} |
256 |
| - |
257 | 181 | pub trait RtioTimer {
|
258 | 182 | fn sleep(&mut self, msecs: u64);
|
259 | 183 | fn oneshot(&mut self, msecs: u64, cb: Box<Callback + Send>);
|
@@ -313,54 +237,3 @@ pub struct IoError {
|
313 | 237 | }
|
314 | 238 |
|
315 | 239 | pub type IoResult<T> = Result<T, IoError>;
|
316 |
| - |
317 |
| -#[deriving(PartialEq, Eq)] |
318 |
| -pub enum IpAddr { |
319 |
| - Ipv4Addr(u8, u8, u8, u8), |
320 |
| - Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16), |
321 |
| -} |
322 |
| - |
323 |
| -impl fmt::Show for IpAddr { |
324 |
| - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
325 |
| - match *self { |
326 |
| - Ipv4Addr(a, b, c, d) => write!(fmt, "{}.{}.{}.{}", a, b, c, d), |
327 |
| - Ipv6Addr(a, b, c, d, e, f, g, h) => { |
328 |
| - write!(fmt, |
329 |
| - "{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}:{:04x}", |
330 |
| - a, b, c, d, e, f, g, h) |
331 |
| - } |
332 |
| - } |
333 |
| - } |
334 |
| -} |
335 |
| - |
336 |
| -#[deriving(PartialEq, Eq)] |
337 |
| -pub struct SocketAddr { |
338 |
| - pub ip: IpAddr, |
339 |
| - pub port: u16, |
340 |
| -} |
341 |
| - |
342 |
| -pub enum StdioContainer { |
343 |
| - Ignored, |
344 |
| - InheritFd(i32), |
345 |
| - CreatePipe(bool, bool), |
346 |
| -} |
347 |
| - |
348 |
| -pub enum ProcessExit { |
349 |
| - ExitStatus(int), |
350 |
| - ExitSignal(int), |
351 |
| -} |
352 |
| - |
353 |
| -pub struct AddrinfoHint { |
354 |
| - pub family: uint, |
355 |
| - pub socktype: uint, |
356 |
| - pub protocol: uint, |
357 |
| - pub flags: uint, |
358 |
| -} |
359 |
| - |
360 |
| -pub struct AddrinfoInfo { |
361 |
| - pub address: SocketAddr, |
362 |
| - pub family: uint, |
363 |
| - pub socktype: uint, |
364 |
| - pub protocol: uint, |
365 |
| - pub flags: uint, |
366 |
| -} |
0 commit comments