i18n_ui 0.2.125

i18n 翻译进度终端界面:交互式并发面板与非交互逐行输出
//! 翻译侧发往渲染线程的事件

use std::time::Duration;

/// 任务名:源语言与目标文件显示路径
pub(crate) struct Name {
  /// 原文语言
  pub(crate) from: String,
  /// 目标文件显示路径(含目标语言目录)
  pub(crate) out: String,
}

pub(crate) enum Event {
  /// 计划:模型任务数与并发上限
  Plan {
    job: usize,
    /// 模型调用并发上限,ETA 按它换算整体吞吐
    concurrency: u16,
    /// 预检阶段确认的缓存命中数,仅用于展示
    cache: usize,
  },
  /// 缓存全命中,不调用模型
  Hit,
  /// 执行阶段发现预检未计入的模型工作
  Grow,
  /// 计划内但本轮未处理(源文件消失、提前失败等),消费一次进度计划量
  Skip,
  /// 开始调用模型(已取得并发名额)
  Start { id: u32, name: Name },
  /// 模型流式输出;`reply` 为 `false` 是思考,`true` 是正文
  Text { id: u32, text: String, reply: bool },
  /// 请求失败,即将换 token / 端点重试;`nth`/`total` 为当前轮次与总轮数,`wait` 为冷却时长
  Retry {
    id: u32,
    nth: usize,
    total: usize,
    wait: Duration,
    base: String,
    err: String,
  },
  /// 任务结束;`err` 为失败原因,`active` 为扣除重试冷却后的有效模型调用耗时
  End {
    id: u32,
    err: Option<String>,
    active: Duration,
  },
  /// 提示信息
  Log(String),
  /// 关闭界面并输出汇总
  Close,
}