pub struct ImportResolver { /* private fields */ }Expand description
The directories a library import is looked up in.
lib_dir is the standard library, which every program can reach.
packages are the packages this program depends on, each under the name
the program imports it by. A package shadows the standard library for the
name it claims, so import "shapes/circle"; reaches the shapes package
whether or not the toolchain ships a module by that name.
Implementations§
Source§impl ImportResolver
impl ImportResolver
Sourcepub fn set_lib_dir(&mut self, dir: PathBuf)
pub fn set_lib_dir(&mut self, dir: PathBuf)
Points library imports at dir instead of the shipped location.
dir is the directory that holds std/, the same thing
CANDELA_LIB_PATH names.
Sourcepub fn add_root(&mut self, name: &str, dir: PathBuf, entry: impl Into<PathBuf>)
pub fn add_root(&mut self, name: &str, dir: PathBuf, entry: impl Into<PathBuf>)
Makes dir the root of the package imported as name, entered
through entry.
entry is the package’s entry file relative to dir, the one its
manifest names or DEFAULT_PACKAGE_ENTRY when it names none.
import "name"; reads that file, and import "name/x"; reads x.cdl
from the entry’s directory. Adding a name twice keeps the last
directory and entry given for it.
Sourcepub fn roots(&self) -> Vec<(SmolStr, PathBuf)>
pub fn roots(&self) -> Vec<(SmolStr, PathBuf)>
The package names and root directories, in the order they were added.
Sourcepub fn root_dirs(&self) -> Vec<PathBuf>
pub fn root_dirs(&self) -> Vec<PathBuf>
The package root directories on their own, which is what a native
library search wants: a package that ships a .so under its root has
it found there.
Sourcepub fn library_path(&self, path: &str) -> Option<PathBuf>
pub fn library_path(&self, path: &str) -> Option<PathBuf>
Where the library import path reads from, or None when there is
nowhere to look.
path carries the .cdl the parser appended, so import "shapes";
arrives as shapes.cdl and import "shapes/circle"; as
shapes/circle.cdl. The leading segment names the package; the rest is
the path inside it, read from the directory of the package’s entry, and
a package with no rest reads the entry itself.
Trait Implementations§
Source§impl Clone for ImportResolver
impl Clone for ImportResolver
Source§fn clone(&self) -> ImportResolver
fn clone(&self) -> ImportResolver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImportResolver
impl Debug for ImportResolver
Auto Trait Implementations§
impl !Send for ImportResolver
impl !Sync for ImportResolver
impl Freeze for ImportResolver
impl RefUnwindSafe for ImportResolver
impl Unpin for ImportResolver
impl UnsafeUnpin for ImportResolver
impl UnwindSafe for ImportResolver
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);