Skip to main content

SwiftManifestJsonParser

Struct SwiftManifestJsonParser 

Source
pub struct SwiftManifestJsonParser;
Expand description

Parses Swift Package Manager manifest files with automatic JSON generation.

§Supported File Formats

  • Package.swift.json - Pre-generated JSON from swift package dump-package
  • Package.swift.deplock - JSON format from DepLock tool
  • Package.swift - Raw Swift source (auto-generates JSON if Swift available)

§Automatic JSON Generation

When scanning raw Package.swift files:

  1. Checks BLAKE3-based cache for previously generated JSON
  2. If cache miss, invokes swift package dump-package (requires Swift toolchain)
  3. Caches result for future scans
  4. 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

Source§

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>

Extracts all packages from the given file path. Read more
Source§

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

Returns the first package from extract_packages(), or a default PackageData if the file contains no packages.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U