[−][src]Enum molt::types::ResultCode
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
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.
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.
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.
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.
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]
fn clone(&self) -> ResultCode
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
fn eq(&self, other: &ResultCode) -> bool
[src]
fn ne(&self, other: &ResultCode) -> bool
[src]
impl StructuralEq for ResultCode
[src]
impl StructuralPartialEq for ResultCode
[src]
Auto Trait Implementations
impl RefUnwindSafe for ResultCode
impl Send for ResultCode
impl Sync for ResultCode
impl Unpin for ResultCode
impl UnwindSafe for ResultCode
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<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?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>,