pub struct SwiftManifestJsonParser;Expand description
Parses Swift Package Manager manifest files with automatic JSON generation.
§Supported File Formats
Package.swift.json- Pre-generated JSON fromswift package dump-packagePackage.swift.deplock- JSON format from DepLock toolPackage.swift- Raw Swift source (auto-generates JSON if Swift available)
§Automatic JSON Generation
When scanning raw Package.swift files:
- Checks BLAKE3-based cache for previously generated JSON
- If cache miss, invokes
swift package dump-package(requires Swift toolchain) - Caches result for future scans
- Falls back gracefully if Swift unavailable (logs warning, returns empty package data)
§Performance
- Pre-generated JSON: <1ms (direct file read)
- Raw Package.swift (cached): <1ms (cache hit)
- Raw Package.swift (first time): ~100-500ms (Swift toolchain execution + cache write)
- Raw Package.swift (no Swift): <1ms (immediate fallback)
§Example
use provenant::parsers::{PackageParser, SwiftManifestJsonParser};
use std::path::Path;
// Works with pre-generated JSON
let json_path = Path::new("Package.swift.json");
let data1 = SwiftManifestJsonParser::extract_first_package(json_path);
// Also works with raw Package.swift (if Swift installed)
let swift_path = Path::new("Package.swift");
let data2 = SwiftManifestJsonParser::extract_first_package(swift_path);Trait Implementations§
Source§impl PackageParser for SwiftManifestJsonParser
impl PackageParser for SwiftManifestJsonParser
Source§const PACKAGE_TYPE: PackageType = PackageType::Swift
const PACKAGE_TYPE: PackageType = PackageType::Swift
Package URL type identifier for this parser (e.g., PackageType::Npm, PackageType::Pypi).
Source§fn extract_packages(path: &Path) -> Vec<PackageData>
fn extract_packages(path: &Path) -> Vec<PackageData>
Extracts all packages from the given file path. Read more
Source§fn is_match(path: &Path) -> bool
fn is_match(path: &Path) -> bool
Checks if the given file path matches this parser’s expected format. Read more
Source§fn extract_first_package(path: &Path) -> PackageData
fn extract_first_package(path: &Path) -> PackageData
Returns the first package from
extract_packages(),
or a default PackageData if the file contains no packages.Auto Trait Implementations§
impl Freeze for SwiftManifestJsonParser
impl RefUnwindSafe for SwiftManifestJsonParser
impl Send for SwiftManifestJsonParser
impl Sync for SwiftManifestJsonParser
impl Unpin for SwiftManifestJsonParser
impl UnsafeUnpin for SwiftManifestJsonParser
impl UnwindSafe for SwiftManifestJsonParser
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> 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