[−][src]Struct ralik::Context
The Context
stores all types, free functions and global variables.
While it can be customized to a large extent, it is suggested to start with the default context, which contains working types for the core types:
let context = Context::new();
The default context can then be extended for the specific use case:
// Define a global variable `$` of the Unit type `()` context.insert_variable("$", Value::new_unit(&context).unwrap());
When starting with an empty context, the core types are not available by default:
let context = Context::new_empty(); Value::new_bool(&context, true).unwrap_err();
Implementations
impl Context
[src]
pub fn get_function(
&self,
key: &str
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
[src]
&self,
key: &str
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
pub fn insert_function(
&self,
key: impl Into<String>,
value: fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
[src]
&self,
key: impl Into<String>,
value: fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
pub fn remove_function(
&self,
key: &str
) -> Option<(String, fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>)>
[src]
&self,
key: &str
) -> Option<(String, fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>)>
impl Context
[src]
pub fn get_macro(
&self,
key: &str
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
[src]
&self,
key: &str
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
pub fn insert_macro(
&self,
key: impl Into<String>,
value: fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
[src]
&self,
key: impl Into<String>,
value: fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>
) -> Option<fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>>
pub fn remove_macro(
&self,
key: &str
) -> Option<(String, fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>)>
[src]
&self,
key: &str
) -> Option<(String, fn(_: &Context, _: &[Value]) -> Result<Value, RuntimeError>)>
impl Context
[src]
pub fn get_type(&self, key: impl AsRef<str>) -> Option<TypeHandle>
[src]
pub fn get_unit_type(&self) -> Result<TypeHandle, InvalidTupleType>
[src]
pub fn get_bool_type(&self) -> Result<TypeHandle, InvalidBoolType>
[src]
pub fn get_char_type(&self) -> Result<TypeHandle, InvalidCharType>
[src]
pub fn get_integer_type(&self) -> Result<TypeHandle, InvalidIntegerType>
[src]
pub fn get_string_type(&self) -> Result<TypeHandle, InvalidStringType>
[src]
pub fn get_tuple_type(
&self,
element_type_names: impl Iterator<Item = impl AsRef<str> + Debug> + Clone
) -> Result<TypeHandle, InvalidTupleType>
[src]
&self,
element_type_names: impl Iterator<Item = impl AsRef<str> + Debug> + Clone
) -> Result<TypeHandle, InvalidTupleType>
pub fn get_array_type(
&self,
element_type_name: &str
) -> Result<TypeHandle, InvalidArrayType>
[src]
&self,
element_type_name: &str
) -> Result<TypeHandle, InvalidArrayType>
pub fn get_option_type(
&self,
element_type_name: &str
) -> Result<TypeHandle, InvalidArrayType>
[src]
&self,
element_type_name: &str
) -> Result<TypeHandle, InvalidArrayType>
pub fn insert_type(&self, value: impl Type + 'static) -> TypeHandle
[src]
impl Context
[src]
pub fn get_variable(&self, key: &str) -> Option<Value>
[src]
pub fn insert_variable(
&self,
key: impl Into<String>,
value: impl Into<Value>
) -> Option<Value>
[src]
&self,
key: impl Into<String>,
value: impl Into<Value>
) -> Option<Value>
pub fn remove_variable(&self, key: &str) -> Option<(String, Value)>
[src]
impl Context
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,