#![allow(unused_imports, dead_code)]
use crate::app_context::AppContext;
use rust_file_generation::{
FillRustFilesDto, FillRustFilesReturnDto, GenerateRustCodeDto, GenerateRustCodeReturnDto,
GenerateRustFilesDto, GenerateRustFilesReturnDto, GenerateRustPromptDto,
GenerateRustPromptReturnDto, rust_file_generation_controller,
};
use common::long_operation::OperationProgress;
pub fn fill_rust_files(
ctx: &AppContext,
dto: &FillRustFilesDto,
) -> Result<FillRustFilesReturnDto, String> {
rust_file_generation_controller::fill_rust_files(&ctx.db_context, &ctx.event_hub, dto)
.map_err(|e| format!("Error while fill_rust_files: {:?}", e))
}
pub fn fill_code_in_rust_files(ctx: &AppContext) -> Result<String, String> {
rust_file_generation_controller::fill_code_in_rust_files(
&ctx.db_context,
&ctx.event_hub,
&mut ctx.long_operation_manager.lock().unwrap(),
)
.map_err(|e| format!("Error while fill_code_in_rust_files: {:?}", e))
}
pub fn get_fill_code_in_rust_files_progress(
ctx: &AppContext,
operation_id: &str,
) -> Result<Option<OperationProgress>, String> {
Ok(
rust_file_generation_controller::get_fill_code_in_rust_files_progress(
&ctx.long_operation_manager.lock().unwrap(),
operation_id,
),
)
}
pub fn get_fill_code_in_rust_files_result(
ctx: &AppContext,
operation_id: &str,
) -> Result<Option<()>, String> {
rust_file_generation_controller::get_fill_code_in_rust_files_result(
&ctx.long_operation_manager.lock().unwrap(),
operation_id,
)
.map_err(|e| {
format!(
"Error while getting fill_code_in_rust_files result: {:?}",
e
)
})
}
pub fn generate_rust_code(
ctx: &AppContext,
dto: &GenerateRustCodeDto,
) -> Result<GenerateRustCodeReturnDto, String> {
rust_file_generation_controller::generate_rust_code(&ctx.db_context, &ctx.event_hub, dto)
.map_err(|e| format!("Error while generate_rust_code: {:?}", e))
}
pub fn generate_rust_files(ctx: &AppContext, dto: &GenerateRustFilesDto) -> Result<String, String> {
rust_file_generation_controller::generate_rust_files(
&ctx.db_context,
&ctx.event_hub,
&mut ctx.long_operation_manager.lock().unwrap(),
dto,
)
.map_err(|e| format!("Error while generate_rust_files: {:?}", e))
}
pub fn get_generate_rust_files_progress(
ctx: &AppContext,
operation_id: &str,
) -> Result<Option<OperationProgress>, String> {
Ok(
rust_file_generation_controller::get_generate_rust_files_progress(
&ctx.long_operation_manager.lock().unwrap(),
operation_id,
),
)
}
pub fn get_generate_rust_files_result(
ctx: &AppContext,
operation_id: &str,
) -> Result<Option<GenerateRustFilesReturnDto>, String> {
rust_file_generation_controller::get_generate_rust_files_result(
&ctx.long_operation_manager.lock().unwrap(),
operation_id,
)
.map_err(|e| format!("Error while getting generate_rust_files result: {:?}", e))
}
pub fn generate_rust_prompt(
ctx: &AppContext,
dto: &GenerateRustPromptDto,
) -> Result<GenerateRustPromptReturnDto, String> {
rust_file_generation_controller::generate_rust_prompt(&ctx.db_context, &ctx.event_hub, dto)
.map_err(|e| format!("Error while generate_rust_prompt: {:?}", e))
}