qleany 1.7.3

Architecture generator for Rust and C++/Qt applications.
// Generated by Qleany v0.0.1 from slint_feature_commands.tera

//! RustFileGeneration feature commands for Slint UI
#![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))
}

/// fill_code_in_rust_files (long operation)
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))
}

/// Get the progress of a generate rust files operation
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,
        ),
    )
}

/// Get the result of a fill_code_in_rust_files operation
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))
}

/// generate_rust_files (long operation)
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))
}

/// Get the progress of a generate rust files operation
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,
        ),
    )
}

/// Get the result of a generate_rust_files operation
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))
}