pub struct Session { /* private fields */ }Expand description
An open dependency-graph session.
Created via Session::open, which loads (or builds) the graph and
resolves the entry module. The background cache writer is joined on drop.
Implementations§
Source§impl Session
impl Session
Sourcepub fn open(entry: &Path, no_cache: bool) -> Result<Self, Error>
pub fn open(entry: &Path, no_cache: bool) -> Result<Self, Error>
Load a dependency graph from entry and resolve the entry module.
When no_cache is true the on-disk cache is bypassed entirely.
Sourcepub fn trace(&self, opts: &TraceOptions) -> TraceResult
pub fn trace(&self, opts: &TraceOptions) -> TraceResult
Trace transitive import weight from the entry module.
Sourcepub fn trace_from(
&self,
file: &Path,
opts: &TraceOptions,
) -> Result<(TraceResult, PathBuf), Error>
pub fn trace_from( &self, file: &Path, opts: &TraceOptions, ) -> Result<(TraceResult, PathBuf), Error>
Trace transitive import weight from an arbitrary file in the graph.
Sourcepub fn resolve_target(&self, arg: &str) -> ResolvedTarget
pub fn resolve_target(&self, arg: &str) -> ResolvedTarget
Resolve a chain/cut argument to a ChainTarget.
If the argument looks like a file path and resolves to a module in
the graph, returns ChainTarget::Module. Otherwise falls through
to a package name lookup.
Sourcepub fn chain(
&self,
target_arg: &str,
include_dynamic: bool,
) -> (ResolvedTarget, Vec<Vec<ModuleId>>)
pub fn chain( &self, target_arg: &str, include_dynamic: bool, ) -> (ResolvedTarget, Vec<Vec<ModuleId>>)
Find all shortest import chains from the entry to a target.
Sourcepub fn cut(
&mut self,
target_arg: &str,
top: i32,
include_dynamic: bool,
) -> (ResolvedTarget, Vec<Vec<ModuleId>>, Vec<CutModule>)
pub fn cut( &mut self, target_arg: &str, top: i32, include_dynamic: bool, ) -> (ResolvedTarget, Vec<Vec<ModuleId>>, Vec<CutModule>)
Find import chains and optimal cut points to sever them.
Sourcepub fn diff_entry(
&mut self,
other: &Path,
opts: &TraceOptions,
) -> Result<(DiffResult, PathBuf), Error>
pub fn diff_entry( &mut self, other: &Path, opts: &TraceOptions, ) -> Result<(DiffResult, PathBuf), Error>
Trace from a different entry point in the same graph and diff against the current entry. Returns the diff and the canonical path of the other entry (avoids redundant canonicalization by the caller).
Sourcepub fn packages(&self) -> &HashMap<String, PackageInfo>
pub fn packages(&self) -> &HashMap<String, PackageInfo>
All third-party packages in the dependency graph.
Sourcepub fn imports(&self, file: &Path) -> Result<Vec<(PathBuf, EdgeKind)>, Error>
pub fn imports(&self, file: &Path) -> Result<Vec<(PathBuf, EdgeKind)>, Error>
List direct imports of a file (outgoing edges).
Sourcepub fn importers(&self, file: &Path) -> Result<Vec<(PathBuf, EdgeKind)>, Error>
pub fn importers(&self, file: &Path) -> Result<Vec<(PathBuf, EdgeKind)>, Error>
List files that import a given file (reverse edge lookup).
Sourcepub fn info(&self, package_name: &str) -> Option<&PackageInfo>
pub fn info(&self, package_name: &str) -> Option<&PackageInfo>
Look up package info by name.
Sourcepub fn entry_label(&self) -> String
pub fn entry_label(&self) -> String
Display label for the current entry point, including the project
directory name for disambiguation (e.g. wrangler/src/index.ts).
Sourcepub fn entry_label_for(&self, path: &Path) -> String
pub fn entry_label_for(&self, path: &Path) -> String
Display label for an arbitrary path, relative to the project root.
Sourcepub fn set_entry(&mut self, path: &Path) -> Result<(), Error>
pub fn set_entry(&mut self, path: &Path) -> Result<(), Error>
Switch the default entry point to a different file in the graph.
The file must already be in the graph (no rebuild). Accepts both absolute paths and paths relative to the project root.
Sourcepub fn watch(&mut self)
pub fn watch(&mut self)
Start watching the project root for file changes.
After calling this, refresh() will short-circuit when no relevant
files have changed since the last refresh. Idempotent: calling
watch() again replaces the existing watcher.
Sourcepub fn is_dirty(&self) -> bool
pub fn is_dirty(&self) -> bool
Whether the watcher has detected changes since the last refresh.
Sourcepub fn refresh(&mut self) -> Result<bool, Error>
pub fn refresh(&mut self) -> Result<bool, Error>
Check for file changes and rebuild the graph if needed.
Returns true if the graph was updated (cold build or module count
changed since the last load).
Sourcepub fn trace_report(
&mut self,
opts: &TraceOptions,
top_modules: i32,
) -> TraceReport
pub fn trace_report( &mut self, opts: &TraceOptions, top_modules: i32, ) -> TraceReport
Trace and produce a display-ready report.
Sourcepub fn trace_from_report(
&self,
file: &Path,
opts: &TraceOptions,
top_modules: i32,
) -> Result<(TraceReport, PathBuf), Error>
pub fn trace_from_report( &self, file: &Path, opts: &TraceOptions, top_modules: i32, ) -> Result<(TraceReport, PathBuf), Error>
Trace from a different file and produce a display-ready report.
Sourcepub fn chain_report(
&self,
target_arg: &str,
include_dynamic: bool,
) -> ChainReport
pub fn chain_report( &self, target_arg: &str, include_dynamic: bool, ) -> ChainReport
Find import chains and produce a display-ready report.
Sourcepub fn cut_report(
&mut self,
target_arg: &str,
top: i32,
include_dynamic: bool,
) -> CutReport
pub fn cut_report( &mut self, target_arg: &str, top: i32, include_dynamic: bool, ) -> CutReport
Find cut points and produce a display-ready report.
Sourcepub fn diff_report(
&mut self,
other: &Path,
opts: &TraceOptions,
limit: i32,
) -> Result<DiffReport, Error>
pub fn diff_report( &mut self, other: &Path, opts: &TraceOptions, limit: i32, ) -> Result<DiffReport, Error>
Diff two entry points and produce a display-ready report.
Sourcepub fn packages_report(&self, top: i32) -> PackagesReport
pub fn packages_report(&self, top: i32) -> PackagesReport
List packages and produce a display-ready report.
pub fn graph(&self) -> &ModuleGraph
pub fn root(&self) -> &Path
pub fn entry(&self) -> &Path
pub fn entry_id(&self) -> ModuleId
pub fn valid_extensions(&self) -> &'static [&'static str]
pub fn from_cache(&self) -> bool
pub fn unresolvable_dynamic_count(&self) -> usize
pub fn unresolvable_dynamic_files(&self) -> &[(PathBuf, usize)]
pub fn file_warnings(&self) -> &[String]
Auto Trait Implementations§
impl Freeze for Session
impl !RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnsafeUnpin for Session
impl !UnwindSafe for Session
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
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>
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>
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more