pub struct Namespace {
pub symbols: Vec<(SmolStr, SymbolKind)>,
pub children: Vec<(SmolStr, Self)>,
pub file: SmolStr,
pub import_path: SmolStr,
}Fields§
§symbols: Vec<(SmolStr, SymbolKind)>§children: Vec<(SmolStr, Self)>§file: SmolStrFor a module bound by an import, the file it was read from, which is
what makes two bindings of one name the same module or two different
ones. Empty for a file’s own scope and a host block.
import_path: SmolStrFor a module bound by an import, its path as the import wrote it
(std/json, ./geometry.cdl), for a message to name it by.
Implementations§
Source§impl Namespace
impl Namespace
pub fn fns(&self) -> impl Iterator<Item = &(SmolStr, SymbolKind)>
pub fn structs(&self) -> impl Iterator<Item = &(SmolStr, SymbolKind)>
Sourcepub fn find_function(
&self,
path: &[SmolStr],
function_name: &str,
) -> Option<usize>
pub fn find_function( &self, path: &[SmolStr], function_name: &str, ) -> Option<usize>
Resolves a function id by name (with an optional module path). Returns
None both when path names no namespace and when the namespace it
names declares no such function; raising is left to the caller, which
is the only place that knows whether another resolution can still
match. A call into a host or dylib namespace is one that can: those
functions are declared in State::dyn_libs and never appear in this
tree.
pub fn find_struct( &self, path: &[SmolStr], struct_name: &str, span: Span, file_idx: u16, sources: &[Source], ) -> Option<usize>
Sourcepub fn find_enum(&self, path: &[SmolStr], enum_name: &str) -> Option<usize>
pub fn find_enum(&self, path: &[SmolStr], enum_name: &str) -> Option<usize>
Resolves an enum type id by name (with an optional module path). Returns
None when no enum by that name exists in the resolved namespace; never
raises a compile error itself so it can be used for speculative
enum-variant resolution against otherwise-unknown call/reference paths.
Sourcepub fn find_template(&self, path: &[SmolStr], type_name: &str) -> Option<usize>
pub fn find_template(&self, path: &[SmolStr], type_name: &str) -> Option<usize>
Resolves a generic declaration by name (with an optional module path)
to its index in Generics::templates. Returns None when the path
names no namespace or the namespace it names declares no generic type
by that name; the caller decides whether another resolution can still
match.
Sourcepub fn resolve(&self, path: &[SmolStr]) -> Option<&Self>
pub fn resolve(&self, path: &[SmolStr]) -> Option<&Self>
The namespace path names, or None when any segment of it is not
declared. Resolution alone is not an error: a path can also name a
host or dylib namespace, which lives in State::dyn_libs.
Sourcepub fn walk_to_namespace(
&self,
path: &[SmolStr],
span: Span,
file_idx: u16,
sources: &[Source],
) -> &Self
pub fn walk_to_namespace( &self, path: &[SmolStr], span: Span, file_idx: u16, sources: &[Source], ) -> &Self
The namespace path names, for a caller that has nowhere else to look:
an unresolvable path ends the compile with the unknown-namespace error.
Trait Implementations§
Auto Trait Implementations§
impl !Send for Namespace
impl !Sync for Namespace
impl Freeze for Namespace
impl RefUnwindSafe for Namespace
impl Unpin for Namespace
impl UnsafeUnpin for Namespace
impl UnwindSafe for Namespace
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);