pub struct MetadataExtractor;Expand description
Metadata extractor for resource files.
Extracts dependency information embedded in resource files:
- Markdown files (.md): YAML frontmatter between
---delimiters - JSON files (.json):
dependenciesfield in the JSON structure - Other files: No dependencies supported
Implementations§
Source§impl MetadataExtractor
impl MetadataExtractor
Sourcepub fn extract(
path: &Path,
content: &str,
variant_inputs: Option<&Value>,
context: Option<&OperationContext>,
) -> Result<DependencyMetadata>
pub fn extract( path: &Path, content: &str, variant_inputs: Option<&Value>, context: Option<&OperationContext>, ) -> Result<DependencyMetadata>
Extract dependency metadata from a file’s content.
Uses operation-scoped context for warning deduplication when provided.
§Arguments
path- Path to the file (used to determine file type)content- Content of the filevariant_inputs- Optional template variables (contains project config and any overrides)context- Optional operation context for warning deduplication
§Returns
DependencyMetadata- Extracted metadata (may be empty)
§Template Support
If variant_inputs is provided, frontmatter is rendered as a Tera template
before parsing, allowing references like:
{{ project.language }} or {{ config.model }}
§Examples
use agpm_cli::core::OperationContext;
use agpm_cli::metadata::MetadataExtractor;
use std::path::Path;
let ctx = OperationContext::new();
let path = Path::new("agent.md");
let content = "---\ndependencies:\n agents:\n - path: helper.md\n---\n# Agent";
let metadata = MetadataExtractor::extract(
path,
content,
None,
Some(&ctx)
).unwrap();Sourcepub fn extract_auto(content: &str) -> Result<DependencyMetadata>
pub fn extract_auto(content: &str) -> Result<DependencyMetadata>
Extract metadata from file content without knowing the file type.
Tries to detect the format automatically.
Auto Trait Implementations§
impl Freeze for MetadataExtractor
impl RefUnwindSafe for MetadataExtractor
impl Send for MetadataExtractor
impl Sync for MetadataExtractor
impl Unpin for MetadataExtractor
impl UnwindSafe for MetadataExtractor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more