pub struct PluginFileSet {
pub files: BTreeMap<String, Vec<u8>>,
pub dir_name: String,
}Expand description
In-memory representation of a loaded plugin directory.
Relative path → raw bytes for every file within the plugin directory.
The map is a BTreeMap so iteration order is deterministic (useful for
tests and for reproducing compilation results across runs).
Fields§
§files: BTreeMap<String, Vec<u8>>All files, keyed by relative path (forward-slash separated, no leading slash).
dir_name: StringThe directory name (used for manifest synthesis when no manifest is found).
Implementations§
Source§impl PluginFileSet
impl PluginFileSet
Sourcepub fn from_map(
dir_name: impl Into<String>,
files: BTreeMap<String, Vec<u8>>,
) -> Result<Self, String>
pub fn from_map( dir_name: impl Into<String>, files: BTreeMap<String, Vec<u8>>, ) -> Result<Self, String>
Build a PluginFileSet from an in-memory map of relative path → bytes.
Applies the same per-file, total-size, and count limits as from_dir.
Rejects any path that contains .. components or an absolute leading /.
This is the seam for tarball extraction and tests — no disk access required.
Sourcepub fn from_dir(path: &Path) -> Result<Self, String>
pub fn from_dir(path: &Path) -> Result<Self, String>
Load a plugin directory from disk.
- Rejects
..components and all symlinks (cycle/escape defense). - Skips files larger than
MAX_PLUGIN_FILE_BYTES. - Fails if more than
MAX_PLUGIN_FILESfiles are found. - Fails if total bytes exceed
MAX_PLUGIN_TOTAL_BYTES.
Sourcepub fn manifest(&self) -> Result<(PluginManifest, Vec<String>), String>
pub fn manifest(&self) -> Result<(PluginManifest, Vec<String>), String>
Resolve the plugin manifest.
A canonical root plugin.json takes precedence when it declares the
Agent Plugins schema. Otherwise discovery falls back to the legacy
.claude-plugin, .codex-plugin, and .cursor-plugin manifests. If no
manifest is found, a minimal one is synthesized from the directory name.
Sourcepub fn text_file(&self, path: &str) -> Option<String>
pub fn text_file(&self, path: &str) -> Option<String>
Retrieve a file’s content as a UTF-8 string, or None if not found or binary.
Sourcepub fn list_dir<'a>(&'a self, dir_prefix: &str) -> Vec<(&'a str, &'a str)>
pub fn list_dir<'a>(&'a self, dir_prefix: &str) -> Vec<(&'a str, &'a str)>
List relative paths that are direct children of dir_prefix/.
Returns (relative_within_dir, full_relative_path).
Sourcepub fn list_dir_recursive<'a>(&'a self, dir_prefix: &str) -> Vec<&'a str>
pub fn list_dir_recursive<'a>(&'a self, dir_prefix: &str) -> Vec<&'a str>
List relative paths for all files under dir_prefix/ (recursively).
Trait Implementations§
Source§impl Clone for PluginFileSet
impl Clone for PluginFileSet
Source§fn clone(&self) -> PluginFileSet
fn clone(&self) -> PluginFileSet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more