-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto merge of #5409 : brson/rust/rt, r=brson
r? There are a lot of commits here, but not all that much substance. Mostly just refactoring. I started sketching out the beginnings of a very simple I/O API in `core::rt::io` that represents I/O streams as a single `Stream` trait instead of `Reader` / `Writer` pairs. This seems to be the more common pattern (at least this is how the .NET BCL does it) and it seems to me that separate readers and writers would make duplex streams very awkward. Regardless, I don't intend to go very far down the I/O API design road without some mailing list discussion. I've also started on the uv bindings for file I/O but haven't gotten very far. Also hooked up the new scheduler to `rust_start` and the compiletest driver. 70% of run-pass test cases already pass, but I wouldn't read too much into that. I also split the direct, low-level uv bindings in two so that the scheduler can have its own set, leaving `std::net` on its own.
- Loading branch information
Showing
29 changed files
with
1,815 additions
and
1,086 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use prelude::*; | ||
use super::super::sched::*; | ||
use super::super::rtio::*; | ||
use super::Stream; | ||
|
||
pub struct FileStream; | ||
|
||
pub impl FileStream { | ||
fn new(_path: Path) -> FileStream { | ||
fail!() | ||
} | ||
} | ||
|
||
impl Stream for FileStream { | ||
fn read(&mut self, _buf: &mut [u8]) -> uint { | ||
fail!() | ||
} | ||
|
||
fn eof(&mut self) -> bool { | ||
fail!() | ||
} | ||
|
||
fn write(&mut self, _v: &const [u8]) { | ||
fail!() | ||
} | ||
} | ||
|
||
#[test] | ||
#[ignore] | ||
fn super_simple_smoke_test_lets_go_read_some_files_and_have_a_good_time() { | ||
let message = "it's alright. have a good time"; | ||
let filename = Path("test.txt"); | ||
let mut outstream = FileStream::new(filename); | ||
outstream.write(message.to_bytes()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use option::*; | ||
use comm::{GenericPort, GenericChan}; | ||
|
||
pub mod file; | ||
|
||
// FIXME #5370 Strongly want this to be StreamError(&mut Stream) | ||
pub struct StreamError; | ||
|
||
// XXX: Can't put doc comments on macros | ||
// Raised by `Stream` instances on error. Returning `true` from the handler | ||
// indicates that the `Stream` should continue, `false` that it should fail. | ||
condition! { | ||
stream_error: super::StreamError -> bool; | ||
} | ||
|
||
pub trait Stream { | ||
/// Read bytes, up to the length of `buf` and place them in `buf`, | ||
/// returning the number of bytes read or an `IoError`. Reads | ||
/// 0 bytes on EOF. | ||
/// | ||
/// # Failure | ||
/// | ||
/// Raises the `reader_error` condition on error | ||
fn read(&mut self, buf: &mut [u8]) -> uint; | ||
|
||
/// Return whether the Reader has reached the end of the stream | ||
fn eof(&mut self) -> bool; | ||
|
||
/// Write the given buffer | ||
/// | ||
/// # Failure | ||
/// | ||
/// Raises the `writer_error` condition on error | ||
fn write(&mut self, v: &const [u8]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.