//! 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 {
}
}
+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 {
/// 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.
///