Expand description
uxi is a package used to build UXI protocol compliant game engines easily. A Client is the main representation of a game engine, refer to its documentation for more information. The commands which engine supports being sent to it from a GUI or other is represented as a Command, refer to its documentation for more details.
Macros§
- error
error!()
resolves to aErr(~RunError::Error)
kind of error, and thus can be called by itself inside a Command to exit the Command with the given error. It supports the same arguments as theformat!
macro.- fatal
fatal!()
resolves to aErr(~RunError::Fatal)
kind of error, and thus can be called by itself inside a Command to exit the Command with the given error and to quit the Client. It is similar to theerror!
macro and supports the same arguments.- quit
quit!()
resolves to aErr(~RunError::Quit)
kind of error, and thus can be called by itself inside a Command to instruct the Client to quit itself and stop executing commands.
Structs§
- Bundle
- Bundle is a packet containing all the relevant context necessary for a Command invocation. It provides access to the values of the flags provided to the command during invocation, the user specific context, and the inbuilt context for use in a Command’s run function. A given Bundle is tied to a Command’s invocation and can’t be used outside that context.
- Bundled
Ctx - A BundledCtx bundles the user-provided context
C
and the inbuilt context into a single type of ease of mutex guarding for concurrency. It provides methods which allow Commands to retrieve information from those contexts. - Client
- Client represents an UXI engine client. It can accept and parse commands
from the GUI and send commands to the GUI though its input and output.
Commands sent from the GUI are automatically parsed and executed according
to the Command schema provided by the user to the Client. The client supports
any UXI type protocol, including but not limited to UCI, UGI, and UAI.
Options can also be added to a Client in the form of parameters.
See the documentation of
Parameter
and theClient::option
function for more details. - Command
- Command represents a runnable UAI command. It contains all the metadata
needed to parse and verify a Command request from the GUI for a Command, and
to run that Command with the current context and the provided flag values.
T
is the context type of the Client, whileE
is the error type.E
must implement theRunError
trait to be usable.
Enums§
- Flag
- Flag is the schema for a single flag of a Command. It directs the Client about how to parse its arguments so that it can be used by its Command. When in a command invocation, a flag starts with its name followed by a number of arguments depending upon its type.
- Parameter
- A Parameter is the schema for one of the Client’s options. An option is a
variable whose state is maintained internally by the Client which can be
used to configure various internal parameters of the game engine, like the
number of threads it uses or its play style. An option’s value can be
changed using
setoption
Command. - RunError
- RunError is the error that is used internally in Client. All user errors must support conversion into this type so that the Client can handle them.
Type Aliases§
- CmdResult
- CmdResult is the Result type returned by a run function. It is
a shorthand for
Result<(), RunError>
. - Guarded
Bundled Ctx - A GuardedBundledCtx is a BundledCtx with a reference-counted mutex guard, which allows it to be used by multiple Commands concurrently without issues.
- RunFn
RunFn<T>
represents the run function of a Command. This function is called with the context (Bundle<T>
) and the flag values whenever the Command is invoked. It returns aCmdResult
which is then handled by the Client.