Module revolver::terminal

source ·
Expand description

An abstract, text-based interface with the user. This module fulfils the ‘read’ and ‘print’ parts of a REPL application.

Structs

Adapts an InputReader closure to the Input trait. The default adapter implementation delegates to stdin.
Mock Terminal implementation, containing delegates for the Terminal::read_line and Terminal::print operations, as well as an invocation tracker.
Adapts an OutputWriter closure to the Output trait. The default adapter implementation delegates to stdout.
Terminal implementation over stream-like input/output abstractions.

Enums

A single invocation of one of the mock’s methods.

Traits

Piecewise abstraction over an input device.
Piecewise abstraction over an output device.
Convenience trait for converting an [Option<(&str, &Result<(), String>)>] from the Invocation::Print variant to the output string slice.
Convenience trait for converting an Option<&Result<String, String>> from the Invocation::ReadLine variant to the input string slice.
Specification of a text-based I/O device for interfacing with the user. Ordinarily, this is a terminal utilising stdin and stdout devices; however, the separation of a concrete terminal device from its specification allows for fine-grained mocking/testing of user interactions.

Functions

Generates a read_line closure that returns one item at a time from a pre-canned slice of lines. If the closure is invoked after the slice is exhausted, it will return an AccessTerminalError.

Type Definitions

Signature of a closure that implements the input side of the terminal device.
Signature of a closure that implements the output side of the terminal device.