refactor: organize host modules and document architecture with UML
Verify Tessera GUI / verify (push) Failing after 2m2s
Verify Tessera GUI / verify (push) Failing after 2m2s
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
//! 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)]
|
||||
pub struct SourceFile {
|
||||
pub id: String,
|
||||
pub path: String,
|
||||
}
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct OpenedSource {
|
||||
pub path: String,
|
||||
pub code: String,
|
||||
}
|
||||
|
||||
pub trait CloudSourceProvider: std::fmt::Debug + Send {
|
||||
fn list_files(&mut self) -> Result<Vec<SourceFile>>;
|
||||
fn open_file(&mut self, id: &str) -> Result<OpenedSource>;
|
||||
}
|
||||
#[derive(Debug, Default)]
|
||||
pub struct SourceWorkspace {
|
||||
pub provider: Option<Box<dyn CloudSourceProvider>>,
|
||||
pub files: Vec<SourceFile>,
|
||||
pub opened: Option<OpenedSource>,
|
||||
pub error: String,
|
||||
}
|
||||
impl SourceWorkspace {
|
||||
pub fn refresh(&mut self) {
|
||||
let Some(provider) = &mut self.provider else {
|
||||
self.error = "No cloud file provider configured".into();
|
||||
return;
|
||||
};
|
||||
match provider.list_files() {
|
||||
Ok(files) => {
|
||||
self.files = files;
|
||||
self.error.clear();
|
||||
}
|
||||
Err(error) => self.error = error.to_string(),
|
||||
}
|
||||
}
|
||||
pub fn open(&mut self, id: &str) {
|
||||
let Some(provider) = &mut self.provider else {
|
||||
return;
|
||||
};
|
||||
match provider.open_file(id) {
|
||||
Ok(source) => {
|
||||
self.opened = Some(source);
|
||||
self.error.clear();
|
||||
}
|
||||
Err(error) => self.error = error.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user