Handle fallout in librustuv

API Changes:

- GetAddrInfoRequest::run() returns Result<Vec<..>, ..>
- Process::spawn() returns Result<(.., Vec<..>), ..>
This commit is contained in:
Kevin Ballard 2014-05-04 00:44:19 -07:00
parent fac0d4e135
commit fa82ef23b8
3 changed files with 8 additions and 7 deletions

View File

@ -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) => {
@ -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;
@ -180,6 +180,6 @@ pub fn accum_addrinfo(addr: &Addrinfo) -> ~[ai::Info] {
}
}
return addrs.move_iter().collect();
addrs
}
}

View File

@ -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() {
@ -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),
}
}

View File

@ -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)
}
@ -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) {