[−][src]Struct papyrus::repl::ReplData
The inner configuration data of the repl.
Fields
cmdtree: Commander<CommandResult<Data>>
The REPL commands as a cmdtree::Commander
.
prompt_colour: Color
The colour of the prompt region. ie papyrus
.
out_colour: Color
The colour of the out component. ie [out0]
.
editing: Option<EditingIndex>
Flag for editing a statement, item, or crate.
If a value is set when an evaluation starts, the input buffer will be used to overwrite the element at the given index (if it exists). Compilation and evaluation could both fail, but the change will not be reverted.
If the index is outside the array bounds then there will be no change. Evaluation phase will still run.
editing_src: Option<String>
The rust source code as a string which is being edited.
This is helpful if an alteration has been requested and you want to
show the old source code. It is recommended to .take()
the value
to avoid repeating the contents.
loaded_libs_size_limit: usize
Limit the number of loaded libraries that are kept in memory and not dropped.
There exists a use pattern which can create segmentation faults if code defined in the library is called once the library goes out of scope and is dropped. Detailed in #44.
Libraries are returned on a successful execution and stored in a vector. Once the vector reaches the size limit, the oldest library is removed and dropped, freeing resources.
The default is to keep the size limit at zero, thus ensuring no libraries are kept in memory. This is recommended unless issues are arising from esoteric use cases.
Methods
impl<D> ReplData<D>
[src]
pub fn with_cmdtree_builder(
&mut self,
builder: Builder<CommandResult<D>>
) -> Result<&mut Self, BuildError>
[src]
&mut self,
builder: Builder<CommandResult<D>>
) -> Result<&mut Self, BuildError>
Uses the given Builder
as the root of the command tree.
An error will be returned if any command already exists.
impl<Data> ReplData<Data>
[src]
pub fn with_compilation_dir<P: AsRef<Path>>(
&mut self,
dir: P
) -> Result<&mut Self>
[src]
&mut self,
dir: P
) -> Result<&mut Self>
Set the compilation directory. The default is set to $HOME/.papyrus
.
pub fn with_external_lib(&mut self, lib: Extern) -> &mut Self
[src]
Link an external library.
This is primarily used for linking the calling library, and there
is a function on Extern
to work this path out. It is better to
use crates.io
than linking libraries, but this method allows for
linking libraries not on crates.io
.
pub fn current_mod(&self) -> &Path
[src]
The current mod that is being repl'd on.
pub fn current_src(&self) -> &SourceCode
[src]
The current source code, this is short hand for
self.mods_map().get(self.current_mod()).unwrap()
.
pub fn mods_map(&self) -> &ModsMap
[src]
The current file map, mappings of modules to source code.
pub fn linking(&self) -> &LinkingConfiguration
[src]
The current linking configuration. Not mutable as it could lead to undefined behaviour if changed.
pub fn persistent_module_code(&mut self) -> &mut String
[src]
A mutable reference to the persistent module code.
This code gets written to each module and can be used to create generic imports. It is also specifically used to solve dependency duplication if an external library is being linked. Dependency duplication is discussed in the linking module.
pub fn static_files(&self) -> &StaticFiles
[src]
The current static files.
pub fn add_static_file(
&mut self,
path: PathBuf,
code: &str
) -> Result<bool, AddingStaticFileError>
[src]
&mut self,
path: PathBuf,
code: &str
) -> Result<bool, AddingStaticFileError>
Add a static file.
The code will be written to disk. The path must be valid, and as they are used for module
paths, must be valid identifiers. See StaticFile
.
pub fn remove_static_file<P: AsRef<Path>>(&mut self, path: P) -> bool
[src]
Remove a static file.
Returns true if the path existed. Any io errors are swallowed.
pub fn clear_loaded_libs(&mut self)
[src]
Clears the cached loaded libraries.
This can be used to clear resources. Loaded libraries are stored up to the
loaded_libs_size_limit
but can be cleared earlier if need be.
pub unsafe fn set_data_type(self, data_type: &str) -> Self
[src]
Not meant to used by developer. Use the macros instead. See linking module
Safety
Incorrect matching of type will cause undefined behaviour when the REPL evaluates. It will most likely segfault. Use is not recommended, rather there are macros that correctly map the type across which are intended for use.
Trait Implementations
Auto Trait Implementations
impl<Data> RefUnwindSafe for ReplData<Data>
impl<Data> Send for ReplData<Data>
impl<Data> Sync for ReplData<Data>
impl<Data> Unpin for ReplData<Data>
impl<Data> UnwindSafe for ReplData<Data>
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<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Erased for 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> Same<T> for T
type Output = T
Should always be Self
impl<E> SpecializationError for E
[src]
default fn not_found<S, T>(
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
[src]
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,