pub struct EnvBuilder { /* private fields */ }Expand description
Used to customize the Environment configuration
NOTE: It is not necessary to use the EnvBuilder if the default environment is acceptable
Implementations§
Source§impl EnvBuilder
impl EnvBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new EnvBuilder, to set the parameters for the MeTTa Environment
NOTE: Unless otherwise specified, the default working directory will be the current process
working dir (cwd)
NOTE: Unless otherwise specified by calling either Self::set_default_config_dir or Self::set_config_dir, the Environment will be configured using no configuration directory.
Depending on the host OS, the config directory locations will be:
- Linux: ~/.config/metta/
- Windows: ~\AppData\Roaming\TrueAGI\metta\config\
- Mac: ~/Library/Application Support/io.TrueAGI.metta/
TODO: Repeat this documentation somewhere more prominent, like the top-level README
Sourcepub fn test_env() -> Self
pub fn test_env() -> Self
A convenience function to construct an environment suitable for unit tests
The test_env Environment will not load or create any files. Additionally
this method will initialize the logger for the test environment
Sourcepub fn set_working_dir(self, working_dir: Option<&Path>) -> Self
pub fn set_working_dir(self, working_dir: Option<&Path>) -> Self
Sets (or unsets) the working_dir for the environment
Sourcepub fn set_config_dir(self, config_dir: &Path) -> Self
pub fn set_config_dir(self, config_dir: &Path) -> Self
Sets the config_dir that the environment will load
Sourcepub fn set_caches_dir(self, caches_dir: &Path) -> Self
pub fn set_caches_dir(self, caches_dir: &Path) -> Self
Sets the directory used for caching files, such as those fetched from remote catalogs
This location will override the default location within the config dir.
Sourcepub fn set_create_config_dir(self, should_create: bool) -> Self
pub fn set_create_config_dir(self, should_create: bool) -> Self
Sets whether or not a config directory with default config files will be created, if no directory is found
NOTE: If the config directory exists but some config files are missing, default files will not be created.
Sourcepub fn set_default_config_dir(self) -> Self
pub fn set_default_config_dir(self) -> Self
Sets the config_dir to the default configuration directory path
Sourcepub fn set_is_test(self, is_test: bool) -> Self
pub fn set_is_test(self, is_test: bool) -> Self
Sets the is_test flag for the environment, to specify whether the environment is a unit-test
NOTE: This currently applies to the logger, but may affect other behaviors in the future. See env_logger::is_test
Sourcepub fn push_include_path<P: AsRef<Path>>(self, path: P) -> Self
pub fn push_include_path<P: AsRef<Path>>(self, path: P) -> Self
Adds additional search paths to search for MeTTa modules in the file system
NOTE: include paths are a type of ModuleCatalog, and the first catalog added will have the highest
search priority, with subsequently added catalogs being search in order. The working_dir will
always be searched before any other catalogs.
Sourcepub fn push_module_catalog<C: ModuleCatalog + 'static>(self, catalog: C) -> Self
pub fn push_module_catalog<C: ModuleCatalog + 'static>(self, catalog: C) -> Self
Adds an additional ModuleCatalog search for MeTTa modules
NOTE: The first catalog added will have the highest search priority, with subsequently added catalogs
being search in order. The working_dir will always be searched before any other catalogs.
Sourcepub fn push_fs_module_format<F: FsModuleFormat + 'static>(self, fmt: F) -> Self
pub fn push_fs_module_format<F: FsModuleFormat + 'static>(self, fmt: F) -> Self
Adds a FsModuleFormat to identify and load modules stored on file-system media
This is the mechanism used to detect and load modules from the file system in foreign formats. For example a format specific to a host language such as Python
NOTE: The first format added will have the highest search priority, with subsequently added formats being tried in order. Built-in formats SingleFileModuleFmt and DirModuleFmt will be tried last.
Sourcepub fn init_common_env(self)
pub fn init_common_env(self)
Initializes the shared common Environment, accessible with Environment::common_env
NOTE: This method will panic if the common Environment has already been initialized
Sourcepub fn try_init_common_env(self) -> Result<(), &'static str>
pub fn try_init_common_env(self) -> Result<(), &'static str>
Initializes the shared common Environment. Non-panicking version of Self::init_common_env
Auto Trait Implementations§
impl !Freeze for EnvBuilder
impl !RefUnwindSafe for EnvBuilder
impl Send for EnvBuilder
impl Sync for EnvBuilder
impl Unpin for EnvBuilder
impl !UnwindSafe for EnvBuilder
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request