refactor(tvix/eval): generalize EvalIO container

Don't restrict to a Box<dyn EvalIO>.

There's still one or two places where we do restrict, this will be
solved by b/262.

Change-Id: Ic8d927d6ea81fa12d90b1e4352f35ffaafbd1adf
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10639
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2024-01-16 14:19:16 +02:00 committed by flokli
parent 44d24852c3
commit e0a867cabf
8 changed files with 74 additions and 48 deletions

View file

@ -224,7 +224,10 @@ pub fn pin_generator(
Box::pin(f)
}
impl<'o> VM<'o> {
impl<'o, IO> VM<'o, IO>
where
IO: AsRef<dyn EvalIO> + 'static,
{
/// Helper function to re-enqueue the current generator while it
/// is awaiting a value.
fn reenqueue_generator(&mut self, name: &'static str, span: LightSpan, generator: Generator) {
@ -411,6 +414,7 @@ impl<'o> VM<'o> {
VMRequest::PathImport(path) => {
let imported = self
.io_handle
.as_ref()
.import_path(&path)
.map_err(|e| ErrorKind::IO {
path: Some(path),
@ -424,6 +428,7 @@ impl<'o> VM<'o> {
VMRequest::ReadToString(path) => {
let content = self
.io_handle
.as_ref()
.read_to_string(&path)
.map_err(|e| ErrorKind::IO {
path: Some(path),
@ -437,6 +442,7 @@ impl<'o> VM<'o> {
VMRequest::PathExists(path) => {
let exists = self
.io_handle
.as_ref()
.path_exists(&path)
.map_err(|e| ErrorKind::IO {
path: Some(path),
@ -451,6 +457,7 @@ impl<'o> VM<'o> {
VMRequest::ReadDir(path) => {
let dir = self
.io_handle
.as_ref()
.read_dir(&path)
.map_err(|e| ErrorKind::IO {
path: Some(path),