From 5639881519a82157cbc23752c3ed973236bcb702 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 14 Sep 2020 16:28:34 -0700 Subject: [PATCH] ctx: import Fd without any types:: prefix --- crates/wasi-common/src/ctx.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/wasi-common/src/ctx.rs b/crates/wasi-common/src/ctx.rs index 1b77b093c4..e73fbb4ea6 100644 --- a/crates/wasi-common/src/ctx.rs +++ b/crates/wasi-common/src/ctx.rs @@ -6,7 +6,7 @@ use crate::sys::osdir::OsDir; use crate::sys::stdio::NullDevice; use crate::sys::stdio::{Stderr, StderrExt, Stdin, StdinExt, Stdout, StdoutExt}; use crate::virtfs::{VirtualDir, VirtualDirEntry}; -use crate::wasi::types; +use crate::wasi::types::Fd; use crate::Error; use std::borrow::Borrow; use std::cell::RefCell; @@ -331,7 +331,7 @@ impl WasiCtxBuilder { struct EntryTable { fd_pool: FdPool, - entries: HashMap>, + entries: HashMap>, } impl EntryTable { @@ -342,25 +342,25 @@ impl EntryTable { } } - fn contains(&self, fd: &types::Fd) -> bool { + fn contains(&self, fd: &Fd) -> bool { self.entries.contains_key(fd) } - fn insert(&mut self, entry: Entry) -> Option { + fn insert(&mut self, entry: Entry) -> Option { let fd = self.fd_pool.allocate()?; self.entries.insert(fd, Rc::new(entry)); Some(fd) } - fn insert_at(&mut self, fd: &types::Fd, entry: Rc) { + fn insert_at(&mut self, fd: &Fd, entry: Rc) { self.entries.insert(*fd, entry); } - fn get(&self, fd: &types::Fd) -> Option> { + fn get(&self, fd: &Fd) -> Option> { self.entries.get(fd).map(Rc::clone) } - fn remove(&mut self, fd: types::Fd) -> Option> { + fn remove(&mut self, fd: Fd) -> Option> { let entry = self.entries.remove(&fd)?; self.fd_pool.deallocate(fd); Some(entry) @@ -390,12 +390,12 @@ impl WasiCtx { } /// Check if `WasiCtx` contains the specified raw WASI `fd`. - pub(crate) fn contains_entry(&self, fd: types::Fd) -> bool { + pub(crate) fn contains_entry(&self, fd: Fd) -> bool { self.entries.borrow().contains(&fd) } /// Get an immutable `Entry` corresponding to the specified raw WASI `fd`. - pub(crate) fn get_entry(&self, fd: types::Fd) -> Result, Error> { + pub(crate) fn get_entry(&self, fd: Fd) -> Result, Error> { match self.entries.borrow().get(&fd) { Some(entry) => Ok(entry), None => Err(Error::Badf), @@ -406,18 +406,18 @@ impl WasiCtx { /// /// The `Entry` will automatically get another free raw WASI `fd` assigned. Note that /// the two subsequent free raw WASI `fd`s do not have to be stored contiguously. - pub(crate) fn insert_entry(&self, entry: Entry) -> Result { + pub(crate) fn insert_entry(&self, entry: Entry) -> Result { self.entries.borrow_mut().insert(entry).ok_or(Error::Mfile) } /// Insert the specified `Entry` with the specified raw WASI `fd` key into the `WasiCtx` /// object. - pub(crate) fn insert_entry_at(&self, fd: types::Fd, entry: Rc) { + pub(crate) fn insert_entry_at(&self, fd: Fd, entry: Rc) { self.entries.borrow_mut().insert_at(&fd, entry) } /// Remove `Entry` corresponding to the specified raw WASI `fd` from the `WasiCtx` object. - pub(crate) fn remove_entry(&self, fd: types::Fd) -> Result, Error> { + pub(crate) fn remove_entry(&self, fd: Fd) -> Result, Error> { self.entries.borrow_mut().remove(fd).ok_or(Error::Badf) }