i18n_ui 0.2.113

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

use std::time::Duration;

/// 任务名:目标语言与源文件显示路径
pub(crate) struct Name {
  pub(crate) lang: String,
  pub(crate) file: String,
}

pub(crate) enum Event {
  /// 进度总量:权重(源文件字节数之和 × 语言数)与任务数
  Plan { weight: u64, job: usize },
  /// 缓存全命中,不调用模型
  Hit { weight: u64 },
  /// 开始调用模型(已取得并发名额)
  Start { id: u32, name: Name, weight: u64 },
  /// 模型流式输出;`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` 为失败原因
  End { id: u32, err: Option<String> },
  /// 提示信息
  Log(String),
  /// 关闭界面并输出汇总
  Close,
}