[][src]Struct papyrus::repl::Repl

pub struct Repl<S, Data> {
    pub data: ReplData<Data>,
    // some fields omitted
}

The repl structure. Stored as a state machine. See the [module level documentation] for more information.

A repl has different available methods depending on its state.

Fields

data: ReplData<Data>

The inner repl configuration data.

Implementations

impl<S, D> Repl<S, D>[src]

These methods are available in any REPL state.

pub fn prompt(&self, colour: bool) -> String[src]

The prompt.

Includes the module name, the editing/mutating state, the command path, the input symbol, and the trailing space. It also includes the colouring byte sequences if specified.

impl<D> Repl<Evaluate, D>[src]

These methods are available when the REPL is in the Evaluate state.

pub fn eval(self, app_data: &mut D) -> EvalResult<D>[src]

Evaluates the read input, compiling and executing the code and printing all line prints until a result is found. This result gets passed back as a print ready repl.

pub fn eval_async(self, app_data: &Arc<Mutex<D>>) -> Evaluating<D> where
    D: 'static + Send
[src]

Same as eval but will evaluate on another thread, not blocking this one.

An Arc::clone will be taken of app_data.

pub fn output_listen(&mut self) -> Receiver[src]

Begin listening to line change events on the output.

pub fn close_channel(&mut self)[src]

Close the sender side of the output channel.

pub fn output(&self) -> &str[src]

The current output.

The output contains colouring ANSI escape codes, the prompt, and all input.

impl<D> Repl<Print, D>[src]

These methods are available when the REPL is in the Print state.

pub fn print(self) -> (Repl<Read, D>, Option<(usize, Kserd<'static>)>)[src]

Prints the result if successful as [out#] or the failure message if any. Uses the default formatter for the Kserd data.

pub fn print_with_formatting(
    self,
    config: FormattingConfig
) -> (Repl<Read, D>, Option<(usize, Kserd<'static>)>)
[src]

Prints the result if successful as [out#] or the failure message if any. Uses the given formatting configuration for the Kserd data. The return is (, <maybe <stmt index, data>>)

impl<D> Repl<Read, D>[src]

These methods are available when the REPL is in the Read state.

pub fn line_input(&mut self, input: &str)[src]

Overwrite the current line in the input buffer.

A line is considered if more input is required, the previous input stacked. Only overwrites the most recent buffer.

pub fn input_buffer(&self) -> &str[src]

The current input buffer.

pub fn input_buffer_line(&self) -> &str[src]

The line of the current input buffer.

This differs to the input buffer if there has been a requirement for More input, say if a block { was started and not closed out. The line is what has be set with line_input.

pub fn read(self) -> ReadResult<D>[src]

Read the current contents of the input buffer. This may move the repl into an evaluating state.

pub fn output(&self) -> &str[src]

The current output.

The output contains colouring ANSI escape codes, the prompt, and all input.

pub fn output_listen(&mut self) -> Receiver[src]

Begin listening to line change events on the output.

pub fn close_channel(&mut self)[src]

Close the sender side of the output channel.

impl<D> Repl<Read, D>[src]

Available with the runnable feature and when the REPL is in the Read state.

pub fn run<T, U, V>(
    self,
    run_callbacks: RunCallbacks<D, T, U, V>
) -> Result<String> where
    T: FnMut(&Repl<Print, D>) -> FormattingConfig,
    U: FnMut(usize, Kserd<'static>, &Repl<Read, D>),
    V: FnOnce(&mut ReplData<D>, &mut D), 
[src]

Run the repl inside the terminal, consuming the repl. Returns the output of the REPL.

Trait Implementations

impl<S: Debug, D> Debug for Repl<S, D>[src]

impl<D> Default for Repl<Read, D>[src]

Auto Trait Implementations

impl<S, Data> RefUnwindSafe for Repl<S, Data> where
    Data: RefUnwindSafe,
    S: RefUnwindSafe

impl<S, Data> Send for Repl<S, Data> where
    Data: Send,
    S: Send

impl<S, Data> Sync for Repl<S, Data> where
    Data: Sync,
    S: Sync

impl<S, Data> Unpin for Repl<S, Data> where
    Data: Unpin,
    S: Unpin

impl<S, Data> UnwindSafe for Repl<S, Data> where
    Data: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

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]

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<E> SpecializationError for E[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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