[][src]Crate rant

Rant

Rant is a language for procedural text generation. It is designed to help you write more dynamic and expressive templates, dialogue, stories, names, test data, and much more.

For language documentation, see the Rant Reference.

The Rant context

All programs are run through a Rant context, represented by the Rant struct. It allows you to execute Rant programs, define and retrieve global variables, manipulate the RNG, and compile Rant code.

Reading compiler errors

You will notice that the Err variant of the Rant::compile* methods is () instead of providing an error list. Instead, errors and warnings are reported via implementors of the Reporter trait, which allows the user to control what happens to messages emitted by the compiler. Currently, Rant has two built-in Reporter implementations: the unit type (), and Vec<CompilerMessage>. You can also make your own custom reporters to suit your specific needs.

Modules

compiler

Structs

ModuleLoadError

Represents an error that occurred when attempting to load a Rant module.

Rant

A Rant execution context.

RantEmpty

Rant's "empty" value.

RantFunction

A function callable from Rant.

RantList

Represents Rant's list type, which stores an ordered collection of values.

RantMap

Represents Rant's map type, which stores a collection of key-value pairs. Map keys are always strings.

RantOptions

Provides options for customizing the creation of a Rant instance.

RantProgram

A compiled Rant program.

Enums

IndexError

Error produced by indexing a RantValue.

KeyError

Error produced by keying a RantValue.

ModuleLoadErrorReason

Represents the reason for which a Rant module failed to load.

RantFunctionInterface

Defines endpoint variants for Rant functions.

RantSpecial

Represents "special" values; opaque data structures for various internal runtime uses.

RantValue

A dynamically-typed Rant value.

RantValueType

A lightweight representation of a Rant value's type.

ValueError

Error produced by a RantValue operator or conversion.

Constants

BUILD_VERSION

The build version according to the crate metadata at the time of compiling.

DEFAULT_PROGRAM_NAME

The default name given to programs compiled from raw strings.

ENV_MODULES_PATH_KEY

The name of the environment variable that Rant checks when checking the global modules path.

RANT_VERSION

The Rant language version implemented by this library.

Traits

AsRantFunction

Trait for converting something to a Rant function.

FromRant

Enables conversion from a RantValue to a native type.

FromRantArgs

Converts from argument list to tuple of impl FromRant values

ToRant

Enables conversion from a native type to a RantValue.

Type Definitions

RantFunctionRef

A reference-counting handle to a Rant function.

RantListRef
RantMapRef
ValueIndexResult

The result type used by Rant value index read operations.

ValueIndexSetResult

The result type used by Rant value index write operations.

ValueKeyResult

The result type used by Rant value key read operations.

ValueKeySetResult

The result type used by Rant value key write operations.

ValueResult

The result type used by Rant value operators and conversion.