summaryrefslogtreecommitdiff
path: root/plugins/warp/src/container.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-03-13 12:24:18 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-24 18:46:48 -0700
commit3c88b11e5df33116580ac008e36092775df66135 (patch)
treecd64fbe149f05683ddabcccd0db7b87356f1f8cf /plugins/warp/src/container.rs
parentf325aa7b6026a1daef84931baeb1f50d7da10c10 (diff)
[WARP] Improved UX and API
- Exposes WARP type objects directly - Adds processor API (for generating warp files directly) - Adds file and chunk API - Misc cleanup - Simplified the amount of commands - Replaced the "Create" commands with a purpose built processor dialog - Added a native QT viewer for WARP files - Simplified committing to a remote with a purpose built commit dialog
Diffstat (limited to 'plugins/warp/src/container.rs')
-rw-r--r--plugins/warp/src/container.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/plugins/warp/src/container.rs b/plugins/warp/src/container.rs
index 4feed24c..bb5d7fd4 100644
--- a/plugins/warp/src/container.rs
+++ b/plugins/warp/src/container.rs
@@ -7,12 +7,14 @@ use std::path::{Path, PathBuf};
use std::str::FromStr;
use thiserror::Error;
use uuid::Uuid;
+use warp::chunk::{Chunk, ChunkKind};
use warp::r#type::guid::TypeGUID;
use warp::r#type::{ComputedType, Type};
use warp::signature::constraint::ConstraintGUID;
use warp::signature::function::{Function, FunctionGUID};
use warp::symbol::Symbol;
use warp::target::Target;
+use warp::WarpFile;
pub mod disk;
pub mod memory;
@@ -291,6 +293,28 @@ pub trait Container: Send + Sync + Display + Debug {
functions: &[Function],
) -> ContainerResult<()>;
+ /// Add the `chunk`s data to the provided `source` if it exists and is writable.
+ fn add_chunk(&mut self, source: &SourceId, chunk: &Chunk) -> ContainerResult<()> {
+ match &chunk.kind {
+ ChunkKind::Signature(sc) => {
+ let functions: Vec<_> = sc.functions().collect();
+ self.add_functions(&chunk.header.target, source, &functions)
+ }
+ ChunkKind::Type(tc) => {
+ let types: Vec<_> = tc.types().collect();
+ self.add_computed_types(source, &types)
+ }
+ }
+ }
+
+ /// Add the `file` data to the provided `source` if it exists and is writable.
+ fn add_file(&mut self, source: &SourceId, file: &WarpFile) -> ContainerResult<()> {
+ for chunk in &file.chunks {
+ self.add_chunk(source, chunk)?;
+ }
+ Ok(())
+ }
+
/// Fetches WARP information for the associated functions.
///
/// Typically, a container that resides only in memory has nothing to fetch, so the default implementation