Expand description
§Ranty
Ranty is a high-level procedural templating language. It is designed to help you write more dynamic and expressive templates, dialogue, stories, names, test data, and much more.
The language reference and CLI documentation live in the repository’s docs/ directory.
§The Ranty context
All programs are run through a Ranty context, represented by the Ranty struct.
It allows you to execute Ranty programs, define and retrieve global variables, manipulate the RNG, and compile Ranty code.
§Reading compiler errors
You will notice that the Err variant of the Ranty::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, Ranty 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§
Macros§
Structs§
- Default
Module Resolver - The default filesystem-based module resolver.
- Lazy
Thunk - Module
Resolve Error - Represents an error that occurred when attempting to load a Ranty module.
- NoModule
Resolver - Stub module resolver that completely disables modules.
- Ranty
- A Ranty execution context.
- Ranty
Function - A function callable from Ranty.
- Ranty
List - Represents Ranty’s
listtype, which stores an ordered, mutable collection of values. - Ranty
List Handle - Reference handle for a Ranty list
- Ranty
Map - Represents Ranty’s
maptype, which stores a mutable collection of key-value pairs. Map keys are always strings. - Ranty
MapHandle - Reference handle for a Ranty map
- Ranty
Nothing - Ranty’s “nothing” value.
- Ranty
Options - Provides options for customizing the creation of a
Rantyinstance. - Ranty
Ordered Collection - Filter type that represents any indexable (ordered) Ranty collection type.
- Ranty
Program - A compiled Ranty program.
- Ranty
Program Info - Contains metadata used to identify a loaded program.
- Ranty
Range - Represents Ranty’s
rangetype, which characterizes a closed range of integers with an exclusive end bound. - Ranty
Selector - Represents a Ranty selector instance used by the resolver to select block branches.
- Ranty
Selector Handle - Reference handle for a Ranty selector.
- Ranty
String - Represents Ranty’s
stringtype. - Ranty
Tuple - Represents Ranty’s
tupletype, which stores an ordered, immutable collection of values. - Ranty
Tuple Handle - Reference handle for a Ranty tuple
- Required
VarArgs - Semantic wrapper around a
Vec<T>. - VarArgs
- Semantic wrapper around a
Vec<T>.
Enums§
- Data
Source Register Error - Represents error states that can occur when registering a data source on a Ranty execution context.
- Index
Error - Error produced by indexing a RantyValue.
- KeyError
- Error produced by keying a RantyValue.
- Lazy
State - Module
Load Error - Represents error states that can occur when loading a module.
- Module
Resolve Error Reason - Represents the reason for which a Ranty module failed to load.
- Ranty
Number - Represents a dynamically-typed Ranty number.
- Ranty
Value - A dynamically-typed Ranty value.
- Ranty
Value Type - A lightweight representation of a Ranty value’s type.
- Ranty
Var - Represents a Ranty variable of one of two flavors: by-value or by-reference.
- Selector
Error - Represents error states of a selector.
- Selector
Mode - Defines available branch selection modes for selectors.
- Slice
Error - Error produced by slicing a RantyValue.
- Value
Error - Error produced by a RantyValue 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.
- RANTY_
COMPAT_ FILE_ EXTENSION - The legacy file extension still accepted for compatibility.
- RANTY_
FILE_ EXTENSION - The preferred file extension for Ranty source files and modules.
- RANTY_
LANG_ VERSION - The Ranty language version implemented by this library.
- RANTY_
SUPPORTED_ FILE_ EXTENSIONS - Supported file extensions in resolution order for extensionless module paths.
- TYPENAME_
BOOL - TYPENAME_
FLOAT - TYPENAME_
FUNCTION - TYPENAME_
INT - TYPENAME_
LIST - TYPENAME_
MAP - TYPENAME_
NOTHING - TYPENAME_
RANGE - TYPENAME_
SELECTOR - TYPENAME_
STRING - TYPENAME_
TUPLE
Traits§
- From
Ranty - From
Ranty Args - Converts from argument list to tuple of
impl TryFromRantyvalues - Into
Ranty - Enables infallible conversion into a
RantyValue. - Into
Ranty Function - Trait for converting something to a Ranty function.
- Module
Resolver - Represents the features required for a module resolver.
- TryFrom
Ranty - Enables fallible conversion from a
RantyValue. - TryInto
Ranty - Enables fallible conversion into a
RantyValue.
Functions§
- collect_
garbage - Immediately runs cycle collection for the current thread’s Ranty heap.
Type Aliases§
- Module
Resolve Result - Result type used by the module loader.
- Ranty
Function Handle - Type alias for the GC-managed function handle type.
- Value
Index Result - The result type used by Ranty value index read operations.
- Value
Index SetResult - The result type used by Ranty value index write operations.
- Value
KeyResult - The result type used by Ranty value key read operations.
- Value
KeySet Result - The result type used by Ranty value key write operations.
- Value
Result - The result type used by Ranty value operators and conversion.
- Value
Slice Result - The result type used by Ranty value slice read operations.
- Value
Slice SetResult - The result type used by Ranty value slice write operations.