docs: explain Tessera modules and execution flows in Chinese
This commit is contained in:
@@ -1,23 +1,32 @@
|
||||
//! 云文件浏览的 provider 抽象与工作区状态。默认 provider 未连接,不假装已有外部文件。
|
||||
//! 列出和打开文件的结果作为工具数据展示,错误保持在当前工具状态中供界面说明。
|
||||
//!
|
||||
//! Cloud source integration seam. The host installs a provider when one exists;
|
||||
//! the default workspace stays disconnected and never fabricates or stores files.
|
||||
use anyhow::Result;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
/// provider 提供的一条文件元数据,供云文件列表显示。
|
||||
pub struct SourceFile {
|
||||
pub id: String,
|
||||
pub path: String,
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
/// 已经取得的源文件内容与标识,不代表它已经被执行。
|
||||
pub struct OpenedSource {
|
||||
pub path: String,
|
||||
pub code: String,
|
||||
}
|
||||
|
||||
/// 外部文件能力接口;只负责列出和读取,不与 VM 全局环境耦合。
|
||||
pub trait CloudSourceProvider: std::fmt::Debug + Send {
|
||||
/// 通过当前 provider 请求文件列表;默认未连接实现返回明确不可用状态。
|
||||
fn list_files(&mut self) -> Result<Vec<SourceFile>>;
|
||||
/// 通过 provider 取得指定文件内容,不在工具查看动作中执行该内容。
|
||||
fn open_file(&mut self, id: &str) -> Result<OpenedSource>;
|
||||
}
|
||||
#[derive(Debug, Default)]
|
||||
/// Sources 云文件页面保留的 provider、列表、选择、内容与错误状态。
|
||||
pub struct SourceWorkspace {
|
||||
pub provider: Option<Box<dyn CloudSourceProvider>>,
|
||||
pub files: Vec<SourceFile>,
|
||||
@@ -25,6 +34,7 @@ pub struct SourceWorkspace {
|
||||
pub error: String,
|
||||
}
|
||||
impl SourceWorkspace {
|
||||
/// 更新云文件列表并保存结果或错误,供 Sources 页面显示。
|
||||
pub fn refresh(&mut self) {
|
||||
let Some(provider) = &mut self.provider else {
|
||||
self.error = "No cloud file provider configured".into();
|
||||
@@ -38,6 +48,7 @@ impl SourceWorkspace {
|
||||
Err(error) => self.error = error.to_string(),
|
||||
}
|
||||
}
|
||||
/// 更新选中文件的内容与打开状态,失败保持可读错误信息。
|
||||
pub fn open(&mut self, id: &str) {
|
||||
let Some(provider) = &mut self.provider else {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user