use std::{io, process::Command}; pub trait SampleModel { fn get_sample(&self) -> Result; } pub struct GPTSampleModel { python_command: String, command_working_path: String, command_args: Vec, } impl SampleModel for GPTSampleModel { fn get_sample(&self) -> Result { let cmd_output = Command::new(&self.python_command) .current_dir(&self.command_working_path) .args(&self.command_args) .output()?; Ok(String::from_utf8_lossy(&cmd_output.stdout).to_string()) } } impl GPTSampleModel { pub fn new( python_command: String, command_working_path: String, command_args: Vec, ) -> GPTSampleModel { Self { python_command: python_command, command_working_path: command_working_path, command_args: command_args, } } }