Enum WeaselError

Source
pub enum WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> {
Show 47 variants GenericError, DuplicatedCreature(CI), DuplicatedObject(OI), DuplicatedTeam(TI), TeamNotFound(TI), CreatureNotFound(CI), ObjectNotFound(OI), NewCreatureUnaccepted(TI, Box<Self>), ConvertedCreatureUnaccepted(TI, CI, Box<Self>), InvalidCreatureConversion(TI, CI), TeamNotEmpty(TI), PositionError(Option<PI>, PI, Box<Self>), EntityNotFound(EI), NonContiguousEventId(EventId, EventId), TurnInProgress, NoTurnInProgress, ActorNotEligible(EI), ActorNotReady(EI), AbilityNotKnown(EI, AI), AbilityNotActivable(EI, AI, Box<Self>), TeamNotReady(TI), PowerNotKnown(TI, WI), PowerNotInvocable(TI, WI, Box<Self>), StatusNotPresent(EI, SI), EmptyEventProcessor, NotACharacter(EI), NotAnActor(EI), NotACreature(EI), NotAnObject(EI), KinshipRelation, SelfRelation, IncompatibleVersions(V, V), BattleEnded, WrongMetricType(MI), ConditionUnsatisfied, DuplicatedEventSink(EventSinkId), InvalidEventRange(Range<EventId>, EventId), EventSinkNotFound(EventSinkId), AuthenticationError(Option<PlayerId>, TI), MissingAuthentication, ServerOnlyEvent, UserEventPackingError(E, String), UserEventUnpackingError(String), InvalidEvent(E, Box<Self>), MultiError(Vec<Self>), UserError(String), EventSinkError(String),
}
Expand description

Error type for all kind of errors generated by weasel.

Variants§

§

GenericError

A generic error.

§

DuplicatedCreature(CI)

Duplicated creature id.

§

DuplicatedObject(OI)

Duplicated object id.

§

DuplicatedTeam(TI)

Duplicated team id.

§

TeamNotFound(TI)

The team doesn’t exist.

§

CreatureNotFound(CI)

The creature doesn’t exist.

§

ObjectNotFound(OI)

The object doesn’t exist.

§

NewCreatureUnaccepted(TI, Box<Self>)

Creation of creatures is disabled.

§

ConvertedCreatureUnaccepted(TI, CI, Box<Self>)

The creature can’t be transferred to the team.

§

InvalidCreatureConversion(TI, CI)

This creature conversion is not valid.

§

TeamNotEmpty(TI)

The team is not empty.

§

PositionError(Option<PI>, PI, Box<Self>)

Position is invalid.

§

EntityNotFound(EI)

The entity doesn’t exist.

§

NonContiguousEventId(EventId, EventId)

The event id is not contiguous.

§

TurnInProgress

A turn is already in progress.

§

NoTurnInProgress

No turn is in progress.

§

ActorNotEligible(EI)

The actor can’t start a new turn.

§

ActorNotReady(EI)

The actor can’t act at the moment.

§

AbilityNotKnown(EI, AI)

The actor doesn’t know such ability.

§

AbilityNotActivable(EI, AI, Box<Self>)

The ability can’t be activated.

§

TeamNotReady(TI)

The team can’t act at the moment.

§

PowerNotKnown(TI, WI)

The team doesn’t possess such power.

§

PowerNotInvocable(TI, WI, Box<Self>)

The power can’t be invoked.

§

StatusNotPresent(EI, SI)

Status not present on a character.

§

EmptyEventProcessor

The event processor is not valid.

§

NotACharacter(EI)

The entity is not a character.

§

NotAnActor(EI)

The entity is not an actor.

§

NotACreature(EI)

The entity is not a creature.

§

NotAnObject(EI)

The entity is not an object.

§

KinshipRelation

Attempt to set Relation::Kin.

§

SelfRelation

Attempt to set relation towards oneself.

§

IncompatibleVersions(V, V)

Two versions of the battle rules are incompatible.

§

BattleEnded

The battle has already ended.

§

WrongMetricType(MI)

The metric’s type is not correct.

§

ConditionUnsatisfied

The EventPrototype’s condition is not satisfied.

§

DuplicatedEventSink(EventSinkId)

Duplicated event sink id.

§

InvalidEventRange(Range<EventId>, EventId)

The event range is invalid.

§

EventSinkNotFound(EventSinkId)

The event sink doesn’t exist.

§

AuthenticationError(Option<PlayerId>, TI)

The player can’t fire the event.

§

MissingAuthentication

No authentication in the event.

§

ServerOnlyEvent

Event can be fired only be the server.

§

UserEventPackingError(E, String)

Failure while packing an user event into a UserEventPacker.

§

UserEventUnpackingError(String)

Failure while unpacking a UserEventPacker into an user event.

§

InvalidEvent(E, Box<Self>)

The event is invalid.

§

MultiError(Vec<Self>)

An error containing multiple inner errors.

§

UserError(String)

An user defined error.

§

EventSinkError(String)

A generic event sink error.

Implementations§

Source§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Source

pub fn unfold(self) -> Self

Unfolds an error, return the inner one in case the original is an InvalidEvent. If not, it returns the original.
In the case of MultiError, unfolds all contained errors.

§Examples
use weasel::{
    battle_rules, error::WeaselErrorType, event::DummyEvent, rules::empty::*, BattleRules,
    EventTrigger, WeaselError,
};

battle_rules! {}
let mut processor = ();
let trigger = DummyEvent::trigger(&mut processor);
let error: WeaselErrorType<CustomRules> =
    WeaselError::InvalidEvent(trigger.event(), Box::new(WeaselError::EmptyEventProcessor));
assert_eq!(error.unfold(), WeaselError::EmptyEventProcessor);
Source

pub fn filter<F>(self, op: F) -> Result<(), Self>
where F: Fn(&Self) -> bool + Copy,

Consumes this error and filters it with the given filter function.

filter is applied to this error, to the error inside InvalidEvent and to all errors contained by MultiError.
Only the errors for which filter returns true are kept.

§Examples
use weasel::{
    battle_rules, error::WeaselErrorType, event::DummyEvent, rules::empty::*, BattleRules,
    EventTrigger, WeaselError,
};

battle_rules! {}
let mut processor = ();
let trigger = DummyEvent::trigger(&mut processor);
let error: WeaselErrorType<CustomRules> =
    WeaselError::InvalidEvent(trigger.event(), Box::new(WeaselError::EmptyEventProcessor));
assert_eq!(
    error
        .filter(|err| {
            if let WeaselError::EmptyEventProcessor = err {
                false
            } else {
                true
            }
        })
        .err(),
    None
);

Trait Implementations§

Source§

impl<V: Clone, TI: Clone, EI: Clone, CI: Clone, OI: Clone, PI: Clone, AI: Clone, WI: Clone, SI: Clone, MI: Clone, E: Clone> Clone for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Source§

fn clone(&self) -> WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, TI: Debug, EI: Debug, CI: Debug, OI: Debug, PI: Debug, AI: Debug, WI: Debug, SI: Debug, MI: Debug, E: Debug> Debug for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Display for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
where V: Debug, TI: Debug, EI: Debug, CI: Debug, OI: Debug, PI: Debug, AI: Debug, WI: Debug, SI: Debug, MI: Debug, E: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: PartialEq, TI: PartialEq, EI: PartialEq, CI: PartialEq, OI: PartialEq, PI: PartialEq, AI: PartialEq, WI: PartialEq, SI: PartialEq, MI: PartialEq, E: PartialEq> PartialEq for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Source§

fn eq( &self, other: &WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>, ) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> StructuralPartialEq for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Auto Trait Implementations§

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Freeze for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
where CI: Freeze, OI: Freeze, TI: Freeze, PI: Freeze, EI: Freeze, AI: Freeze, WI: Freeze, SI: Freeze, V: Freeze, MI: Freeze, E: Freeze,

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> RefUnwindSafe for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Send for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
where CI: Send, OI: Send, TI: Send, PI: Send, EI: Send, AI: Send, WI: Send, SI: Send, V: Send, MI: Send, E: Send,

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Sync for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
where CI: Sync, OI: Sync, TI: Sync, PI: Sync, EI: Sync, AI: Sync, WI: Sync, SI: Sync, V: Sync, MI: Sync, E: Sync,

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> Unpin for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>
where CI: Unpin, OI: Unpin, TI: Unpin, PI: Unpin, EI: Unpin, AI: Unpin, WI: Unpin, SI: Unpin, V: Unpin, MI: Unpin, E: Unpin,

§

impl<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E> UnwindSafe for WeaselError<V, TI, EI, CI, OI, PI, AI, WI, SI, MI, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V