Skip to main content

DataAccess

Trait DataAccess 

Source
pub trait DataAccess: Send + Sync {
    // Required methods
    fn read_bytes(&self, item: &ItemRef) -> BinocResult<Vec<u8>>;
    fn open_read(&self, item: &ItemRef) -> BinocResult<Box<dyn Read + Send>>;
    fn local_path(&self, item: &ItemRef) -> BinocResult<PathBuf>;
    fn provide(
        &self,
        logical_path: &str,
        content: &[u8],
    ) -> BinocResult<ItemRef>;
    fn workspace(&self) -> BinocResult<PathBuf>;
    fn register_local(
        &self,
        physical: &Path,
        logical: &str,
    ) -> BinocResult<ItemRef>;
    fn publish_artifact(
        &self,
        format: &ArtifactFormat,
        subject: ArtifactSubject,
        producer: &str,
        data: &[u8],
    ) -> BinocResult<ArtifactDescriptor>;
    fn get_artifact(
        &self,
        descriptor: &ArtifactDescriptor,
    ) -> BinocResult<Option<Vec<u8>>>;
    fn data_root(&self) -> BinocResult<PathBuf>;
}
Expand description

Mediates all data I/O for plugins. Replaces direct filesystem access (Item.physical_path) and shared mutable context (CompareContext).

In-process: backed by the local filesystem + temp dirs. Cross-ABI: backed by a shared data_root directory so host and plugin can exchange artifacts via publish_artifact()/get_artifact().

Required Methods§

Source

fn read_bytes(&self, item: &ItemRef) -> BinocResult<Vec<u8>>

Read the full contents of an item as bytes.

Source

fn open_read(&self, item: &ItemRef) -> BinocResult<Box<dyn Read + Send>>

Open a streaming reader for an item.

Source

fn local_path(&self, item: &ItemRef) -> BinocResult<PathBuf>

Get a local filesystem path for tools that require one (e.g. SQLite). Not available on all backends — prefer read_bytes/open_read.

Source

fn provide(&self, logical_path: &str, content: &[u8]) -> BinocResult<ItemRef>

Make new data available as an item (for container expansion). Returns an ItemRef usable in child ItemPairs.

Source

fn workspace(&self) -> BinocResult<PathBuf>

Get a fresh writable workspace directory. Managed by the DataAccess — cleaned up when the diff operation completes.

Source

fn register_local(&self, physical: &Path, logical: &str) -> BinocResult<ItemRef>

Register a local filesystem path as a known item. Returns an ItemRef that can be used in child ItemPairs.

Source

fn publish_artifact( &self, format: &ArtifactFormat, subject: ArtifactSubject, producer: &str, data: &[u8], ) -> BinocResult<ArtifactDescriptor>

Publish an artifact: store opaque bytes and return a descriptor.

Artifacts are the unified mechanism for both private reuse and cross-plugin composition. A comparator or transformer publishes zero or more artifacts per node; downstream plugins retrieve them by format and subject.

format is a structured (package, name, version) tuple — see ArtifactFormat. subject indicates which side of the comparison the artifact describes. producer is the plugin name for provenance. The returned ArtifactDescriptor should be attached to the node via DiffNode.artifacts.

Source

fn get_artifact( &self, descriptor: &ArtifactDescriptor, ) -> BinocResult<Option<Vec<u8>>>

Retrieve the bytes for a previously published artifact.

Source

fn data_root(&self) -> BinocResult<PathBuf>

Session-level root directory shared between host and plugins. Artifact files live under <data_root>/.artifacts/. ABI requests carry this path so native plugins can construct a LocalDataAccess that reads from the same artifact store.

Implementors§