Address a few XXX comments throughout the runtime

* Implement Seek for Option<Seek>
* Remove outdated comment for io::process
* De-pub a component which didn't need to be pub
This commit is contained in:
Alex Crichton 2013-10-15 20:55:50 -07:00
parent 1db783bdcf
commit c6fa4e277f
3 changed files with 20 additions and 12 deletions

View File

@ -332,8 +332,7 @@ pub mod native {
mod mock;
/// The default buffer size for various I/O operations
/// XXX: Not pub
pub static DEFAULT_BUF_SIZE: uint = 1024 * 64;
static DEFAULT_BUF_SIZE: uint = 1024 * 64;
/// The type passed to I/O condition handlers to indicate error
///

View File

@ -13,11 +13,9 @@
//! I/O constructors return option types to allow errors to be handled.
//! These implementations allow e.g. `Option<FileStream>` to be used
//! as a `Reader` without unwrapping the option first.
//!
//! # XXX Seek and Close
use option::*;
use super::{Reader, Writer, Listener, Acceptor};
use super::{Reader, Writer, Listener, Acceptor, Seek, SeekStyle};
use super::{standard_error, PreviousIoError, io_error, read_error, IoError};
fn prev_io_error() -> IoError {
@ -62,6 +60,24 @@ impl<R: Reader> Reader for Option<R> {
}
}
impl<S: Seek> Seek for Option<S> {
fn tell(&self) -> u64 {
match *self {
Some(ref seeker) => seeker.tell(),
None => {
io_error::cond.raise(prev_io_error());
0
}
}
}
fn seek(&mut self, pos: i64, style: SeekStyle) {
match *self {
Some(ref mut seeker) => seeker.seek(pos, style),
None => io_error::cond.raise(prev_io_error())
}
}
}
impl<T, A: Acceptor<T>, L: Listener<T, A>> Listener<T, A> for Option<L> {
fn listen(self) -> Option<A> {
match self {

View File

@ -70,13 +70,6 @@ pub enum StdioContainer {
/// specified for.
InheritFd(libc::c_int),
// XXX: these two shouldn't have libuv-specific implementation details
/// The specified libuv stream is inherited for the corresponding file
/// descriptor it is assigned to.
// XXX: this needs to be thought out more.
//InheritStream(uv::net::StreamWatcher),
/// Creates a pipe for the specified file descriptor which will be directed
/// into the previously-initialized pipe passed in.
///