pub struct Scope { /* private fields */ }
Expand description
Variables, functions and mixins are defined in a Scope
.
A scope can be a local scope, e.g. in a function, or the global scope. All non-global scopes have a parent. The global scope is global to a sass document, multiple different global scopes may exists in the same rust-language process.
Scopes are often accessed through a ScopeRef
.
Implementations
sourceimpl<'a> Scope
impl<'a> Scope
sourcepub fn new_global(format: Format) -> Self
pub fn new_global(format: Format) -> Self
Create a new global scope.
A “global” scope is just a scope that have no parent. There will be multiple global scopes existing during the evaluation of a single sass file.
sourcepub fn builtin_module(name: &'static str) -> Self
pub fn builtin_module(name: &'static str) -> Self
Create a scope for a built-in module.
sourcepub fn sub_selectors(parent: ScopeRef, selectors: Selectors) -> Self
pub fn sub_selectors(parent: ScopeRef, selectors: Selectors) -> Self
Create a new subscope of a given parent with selectors.
sourcepub fn define_module(&self, name: String, module: ScopeRef)
pub fn define_module(&self, name: String, module: ScopeRef)
Define a module in the scope.
This is used by the @use
statement.
sourcepub fn get_module(&self, name: &str) -> Option<ScopeRef>
pub fn get_module(&self, name: &str) -> Option<ScopeRef>
Get a module.
This is used when refering to a function or variable with namespace.name notation.
sourcepub fn get_format(&self) -> Format
pub fn get_format(&self) -> Format
Get the format used in this scope.
sourcepub fn set_variable(&self, name: Name, val: Value, default: bool, global: bool)
pub fn set_variable(&self, name: Name, val: Value, default: bool, global: bool)
Define a variable with a value.
The $
sign is not included in name
.
sourcepub fn define_global(&self, name: Name, val: Value)
pub fn define_global(&self, name: Name, val: Value)
Define a variable in the global scope that is an ultimate parent of this scope.
sourcepub fn define_multi(&self, names: &[Name], value: &Value)
pub fn define_multi(&self, names: &[Name], value: &Value)
Define multiple names from a value that is a list. Special case: in names is a single name, value is used directly.
sourcepub fn get_or_none(&self, name: &Name) -> Option<Value>
pub fn get_or_none(&self, name: &Name) -> Option<Value>
Get the Value for a variable.
sourcepub fn get(&self, name: &Name) -> Result<Value, ScopeError>
pub fn get(&self, name: &Name) -> Result<Value, ScopeError>
Get the value for a variable (or an error).
sourcepub fn store_local_values(&self, names: &[Name]) -> Vec<(Name, Option<Value>)>
pub fn store_local_values(&self, names: &[Name]) -> Vec<(Name, Option<Value>)>
Copy a set of local variables to a temporary holder
sourcepub fn restore_local_values(&self, data: Vec<(Name, Option<Value>)>)
pub fn restore_local_values(&self, data: Vec<(Name, Option<Value>)>)
Restore a set of local variables from a temporary holder
sourcepub fn get_global_or_none(&self, name: &Name) -> Option<Value>
pub fn get_global_or_none(&self, name: &Name) -> Option<Value>
Get the global Value for a variable.
sourcepub fn get_mixin(&self, name: &Name) -> Option<MixinDecl>
pub fn get_mixin(&self, name: &Name) -> Option<MixinDecl>
Get a mixin by name.
Returns the formal args and the body of the mixin.
sourcepub fn define_mixin(&self, name: Name, mixin: MixinDecl)
pub fn define_mixin(&self, name: Name, mixin: MixinDecl)
Define a mixin.
sourcepub fn define_function(&self, name: Name, func: Function)
pub fn define_function(&self, name: Name, func: Function)
Define a function.
sourcepub fn get_function(&self, name: &Name) -> Result<Option<Function>, Error>
pub fn get_function(&self, name: &Name) -> Result<Option<Function>, Error>
Get a function by name.
sourcepub fn get_selectors(&self) -> &Selectors
pub fn get_selectors(&self) -> &Selectors
Get the selectors active for this scope.
sourcepub fn functions_map(&self) -> Value
pub fn functions_map(&self) -> Value
Get the functions of this scope as a Value::Map
.
sourcepub fn variables_map(&self) -> Value
pub fn variables_map(&self) -> Value
Get the variables of this scope as a Value::Map
.
sourcepub fn forward(&self) -> ScopeRef
pub fn forward(&self) -> ScopeRef
Get the forward scope for this scope.
Create a new one if necessary.
sourcepub fn opt_forward(&self) -> Option<ScopeRef>
pub fn opt_forward(&self) -> Option<ScopeRef>
Get the forward scope for this scope.
Create a new one if necessary.
Auto Trait Implementations
impl RefUnwindSafe for Scope
impl Send for Scope
impl Sync for Scope
impl Unpin for Scope
impl UnwindSafe for Scope
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more