Skip to content

Commit

Permalink
Handle fallout in librustuv
Browse files Browse the repository at this point in the history
API Changes:

- GetAddrInfoRequest::run() returns Result<Vec<..>, ..>
- Process::spawn() returns Result<(.., Vec<..>), ..>
  • Loading branch information
lilyball committed May 8, 2014
1 parent fac0d4e commit fa82ef2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/librustuv/addrinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub struct GetAddrInfoRequest;

impl GetAddrInfoRequest {
pub fn run(loop_: &Loop, node: Option<&str>, service: Option<&str>,
hints: Option<ai::Hint>) -> Result<~[ai::Info], UvError> {
hints: Option<ai::Hint>) -> Result<Vec<ai::Info>, UvError> {
assert!(node.is_some() || service.is_some());
let (_c_node, c_node_ptr) = match node {
Some(n) => {
Expand Down Expand Up @@ -134,7 +134,7 @@ fn each_ai_flag(_f: |c_int, ai::Flag|) {
}

// Traverse the addrinfo linked list, producing a vector of Rust socket addresses
pub fn accum_addrinfo(addr: &Addrinfo) -> ~[ai::Info] {
pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<ai::Info> {
unsafe {
let mut addr = addr.handle;

Expand Down Expand Up @@ -180,6 +180,6 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> ~[ai::Info] {
}
}

return addrs.move_iter().collect();
addrs
}
}
5 changes: 3 additions & 2 deletions src/librustuv/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ impl Process {
/// Returns either the corresponding process object or an error which
/// occurred.
pub fn spawn(io_loop: &mut UvIoFactory, config: process::ProcessConfig)
-> Result<(Box<Process>, ~[Option<PipeWatcher>]), UvError> {
-> Result<(Box<Process>, Vec<Option<PipeWatcher>>), UvError>
{
let cwd = config.cwd.map(|s| s.to_c_str());
let mut io = vec![config.stdin, config.stdout, config.stderr];
for slot in config.extra_io.iter() {
Expand Down Expand Up @@ -102,7 +103,7 @@ impl Process {
});

match ret {
Ok(p) => Ok((p, ret_io.move_iter().collect())),
Ok(p) => Ok((p, ret_io)),
Err(e) => Err(e),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustuv/uvio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl IoFactory for UvIoFactory {
}

fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
hint: Option<ai::Hint>) -> Result<~[ai::Info], IoError> {
hint: Option<ai::Hint>) -> Result<Vec<ai::Info>, IoError> {
let r = GetAddrInfoRequest::run(&self.loop_, host, servname, hint);
r.map_err(uv_error_to_io_error)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ impl IoFactory for UvIoFactory {

fn spawn(&mut self, config: ProcessConfig)
-> Result<(Box<rtio::RtioProcess:Send>,
~[Option<Box<rtio::RtioPipe:Send>>]),
Vec<Option<Box<rtio::RtioPipe:Send>>>),
IoError>
{
match Process::spawn(self, config) {
Expand Down

0 comments on commit fa82ef2

Please sign in to comment.