EnvBuilder

Struct EnvBuilder 

Source
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

Source

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

Source

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

Source

pub fn set_working_dir(self, working_dir: Option<&Path>) -> Self

Sets (or unsets) the working_dir for the environment

Source

pub fn set_config_dir(self, config_dir: &Path) -> Self

Sets the config_dir that the environment will load

Source

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.

Source

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.

Source

pub fn set_default_config_dir(self) -> Self

Sets the config_dir to the default configuration directory path

Source

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

Source

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.

Source

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.

Source

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.

Source

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

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> RefOrMove<T> for T

§

fn as_value(self) -> T

§

fn as_ref(&self) -> &T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more