Skip to content

Commit

Permalink
revert: remove unnecessary FileHandler
Browse files Browse the repository at this point in the history
Signed-off-by: WoodenMaiden <[email protected]>
  • Loading branch information
WoodenMaiden committed Nov 21, 2023
1 parent 9ea2ba7 commit 8001149
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions agent/lib/src/runner_engine/model.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
use anyhow::Result;
use std::{
fs::File,
io::{Read, Write},
path::Path,
path::PathBuf,
};
use std::path::PathBuf;

use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -55,32 +49,3 @@ impl CodeReturn {
}
}
}

/// A trait responsible for CRU operations on files and dir
/// Mainly used in tests to mock file operations
trait FileHandler: Read + Write {
fn create<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized;
fn read<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized;
}

impl FileHandler for File {
fn create<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized,
{
let file = File::create(path)?;
Ok(file)
}

fn read<P: AsRef<Path>>(path: P) -> Result<Self>
where
Self: Sized,
{
let file = File::open(path)?;
Ok(file)
}
}

0 comments on commit 8001149

Please sign in to comment.