Skip to main content

ReadPackageHook

Trait ReadPackageHook 

Source
pub trait ReadPackageHook: Send {
    // Required method
    fn read_package<'a>(
        &'a mut self,
        pkg: VersionMetadata,
    ) -> Pin<Box<dyn Future<Output = Result<VersionMetadata, String>> + Send + 'a>>;
}
Expand description

Hook invoked once per resolved package, right after its version has been picked from the packument and before its dependency set is enqueued. Implementations may mutate dependencies, optionalDependencies, peerDependencies, and peerDependenciesMeta; every other field is ignored on the way back, matching how pnpm’s readPackage hook is used in the wild.

The trait is deliberately shaped to let a single long-lived node subprocess implement it — &mut self so the impl can own stdin / stdout halves of the child without interior mutability, and a boxed future because async fn in dyn-compatible traits still requires third-party crates we haven’t pulled in.

Required Methods§

Source

fn read_package<'a>( &'a mut self, pkg: VersionMetadata, ) -> Pin<Box<dyn Future<Output = Result<VersionMetadata, String>> + Send + 'a>>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§