[][src]Enum molt::types::ResultCode

pub enum ResultCode {
    Okay,
    Error,
    Return,
    Break,
    Continue,
    Other(MoltInt),
}

This enum represents the different kinds of Exception that result from evaluating a Molt script.

Client Rust code will usually see only the Error code; the others will most often be caught and handled within the interpreter. However, client code may explicitly catch and handle Break and Continue (or application-defined codes) at both the Rust and the TCL level in order to implement application-specific control structures. (See The Molt Book on the return and catch commands for more details on the TCL interface.)

Variants

Okay

Value for return -code to indicate returning an Ok(value) higher up the stack. Client code should rarely if ever need to refer to this constant explicitly.

Error

A Molt error. The Exception::value is the error message for display to the user. The molt_err! and molt_throw! macros are usually used to produce errors in client code; but the Exception struct has a number of methods that give finer grained control.

Return

An explicit return from a Molt procedure. The Exception::value is the returned value, or the empty value if return was called without a return value. This result will bubble up through one or more stack levels (i.e., enclosing TCL procedure calls) and then yield the value as a normal Ok result. If it is received when evaluating an arbitrary script, i.e., if return is called outside of any procedure, the interpreter will convert it into a normal Ok result.

Clients will rarely need to interact with or reference this result code explicitly, unless implementing application-specific control structures. See The Molt Book documentation for the return and catch command for the semantics.

Break

A break in a Molt loop. It will break out of the inmost enclosing loop in the usual way. If it is returned outside a loop (or some user-defined control structure that supports break), the interpreter will convert it into an Error.

Clients will rarely need to interact with or reference this result code explicitly, unless implementing application-specific control structures. See The Molt Book documentation for the return and catch command for the semantics.

Continue

A continue in a Molt loop. Execution will continue with the next iteration of the inmost enclosing loop in the usual way. If it is returned outside a loop (or some user-defined control structure that supports break), the interpreter will convert it into an error.

Clients will rarely need to interact with or reference this result code explicitly, unless implementing application-specific control structures. See The Molt Book documentation for the return and catch command for the semantics.

Other(MoltInt)

A mechanism for defining application-specific result codes. Clients will rarely need to interact with or reference this result code explicitly, unless implementing application-specific control structures. See The Molt Book documentation for the return and catch command for the semantics.

Implementations

impl ResultCode[src]

pub fn from_value(value: &Value) -> Result<Self, Exception>[src]

A convenience: retrieves a result code string from the input Value the enumerated value as an external type, converting it from Option<ResultCode> into Result<ResultCode,Exception>.

This is primarily intended for use by the return command; if you really need it, you'd best be familiar with the implementation of return in command.rs, as well as a good bit of interp.rs.

pub fn as_int(&self) -> MoltInt[src]

Returns the result code as an integer.

This is primarily intended for use by the catch command.

Trait Implementations

impl Clone for ResultCode[src]

impl Copy for ResultCode[src]

impl Debug for ResultCode[src]

impl Display for ResultCode[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Formats a result code for use with the return command's -code option. This is part of making ResultCode a valid external type for use with Value.

impl Eq for ResultCode[src]

impl FromStr for ResultCode[src]

type Err = String

The associated error which can be returned from parsing.

fn from_str(value: &str) -> Result<Self, Self::Err>[src]

Converts a symbolic or numeric result code into a ResultCode. This is part of making ResultCode a valid external type for use with Value.

impl PartialEq<ResultCode> for ResultCode[src]

impl StructuralEq for ResultCode[src]

impl StructuralPartialEq for ResultCode[src]

Auto Trait Implementations

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<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.