pub enum RollError {
    DieTypeInvalid,
    DiceExceedLimit,
    NoDiceToRoll,
    ParsingError,
}
Expand description

The different types of errors that may occur trying to construct a Roll from a given input string.

Variants

DieTypeInvalid

Signifies that the inputted die type did not match any of the valid types.

Valid die types are: d2, d4, d6, d8, d10, d12, d20, d100

Example

use die_parser::{Roll, RollError};

let invalid_roll = Roll::parse_roll("1d50");
assert_eq!(invalid_roll, Err(RollError::DieTypeInvalid));

DiceExceedLimit

Signifies that the requested amount of dice exceeded the set limit.

Example

use die_parser::{Roll, RollError};

let invalid_roll = Roll::parse_roll("9001d20");
assert_eq!(invalid_roll, Err(RollError::DiceExceedLimit));

NoDiceToRoll

Signifies that the requested amount of dice was less than 1.

Example

use die_parser::{Roll, RollError};

let invalid_roll = Roll::parse_roll("0d20");
assert_eq!(invalid_roll, Err(RollError::NoDiceToRoll));

ParsingError

Signifies that the input string was malformed.

Example

use die_parser::{Roll, RollError};

let invalid_roll = Roll::parse_roll("4invalid_charactersd20+5");
assert_eq!(invalid_roll, Err(RollError::ParsingError));

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The lower-level source of this error, if any. Read more

🔬 This is a nightly-only experimental API. (backtrace)

Returns a stack backtrace, if available, of where this error occurred. Read more

👎 Deprecated since 1.42.0:

use the Display impl or to_string()

👎 Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.