macro_rules! impl_parse_result {
($type:ty, $dep_type:ty {
dependencies: $dependencies:ident,
uri: $uri:ident
$(, workspace_root: $workspace_root:ident)?
$(, dependency_truncation: $dependency_truncation:ident)?
$(, blocked_registries: $blocked_registries:ident)?
$(, rejected_registries: $rejected_registries:ident)?
$(,)?
}) => { ... };
}Expand description
Implement ParseResult trait for a struct.
§Arguments
$type- The struct type name$dep_type- The dependency type that implementsDependencydependencies- Field name for dependencies vec (Vec<DepType>)uri- Field name for document URI (Url)workspace_root- Optional: field name for workspace root (Option<PathBuf>)dependency_truncation- Optional: field name for theOption<(usize, usize)>ecosystem::ParseResult::dependency_truncationoverride (#796) — omit when the parser has nocrate::DependencyBudgetwired in yet (the trait defaultNoneapplies).blocked_registries- Optional: field name for theVec<BlockedRegistryOccurrence>ecosystem::ParseResult::blocked_registriesoverride (#925, #969), read via.clone()— omit when the ecosystem enforces no configurable-registry reachability policy (the trait default emptyVecapplies).rejected_registries- Optional: field name for theVec<RejectedRegistryOccurrence>ecosystem::ParseResult::rejected_registriesoverride (#1438), read via.clone()— omit when the ecosystem produces noInvalidEntry-based rejections beyond the blocked-host case (the trait default emptyVecapplies).
All optional fields are given in the fixed order shown above — workspace_root, then
dependency_truncation, then blocked_registries, then rejected_registries — any
subset may be omitted, but a present field cannot appear out of order.
§Examples
ⓘ
use deps_core::impl_parse_result;
pub struct MyParseResult {
pub dependencies: Vec<MyDependency>,
pub uri: Url,
pub dependency_truncation: Option<(usize, usize)>,
}
impl_parse_result!(MyParseResult, MyDependency {
dependencies: dependencies,
uri: uri,
});
// With workspace root and/or dependency-truncation tracking:
impl_parse_result!(MyParseResult, MyDependency {
dependencies: dependencies,
uri: uri,
workspace_root: workspace_root,
dependency_truncation: dependency_truncation,
});
// With a policy-blocked-registry override too:
impl_parse_result!(MyParseResult, MyDependency {
dependencies: dependencies,
uri: uri,
dependency_truncation: dependency_truncation,
blocked_registries: blocked_registries,
});