[][src]Enum evtclib::AgentKind

pub enum AgentKind {
    Player(Player),
    Gadget(Gadget),
    Character(Character),
}

The type of an agent.

arcdps differentiates between three types of agents: Player, Character and Gadget. This enum unifies handling between them by allowing you to pattern match or use one of the accessor methods.

The main way to obtain a AgentKind is by using the .kind() method on an Agent. In cases where you already have a raw::Agent available, you can also use the TryFrom/TryInto traits to convert a raw::Agent or &raw::Agent to a AgentKind:

use std::convert::TryInto;
// Get a raw::Agent from somewhere
let raw_agent: raw::Agent = panic!();
// Convert it
let agent: AgentKind = raw_agent.try_into().unwrap();

Variants

Player(Player)

The agent is a player.

The player-specific data is in the included Player struct.

Gadget(Gadget)

The agent is a gadget.

The gadget-specific data is in the included Gadget struct.

Character(Character)

The agent is a character.

The character-specific data is in the included Character struct.

Implementations

impl AgentKind[src]

pub fn as_player(&self) -> Option<&Player>[src]

Accesses the inner Player struct, if available.

pub fn is_player(&self) -> bool[src]

Determines whether this AgentKind contains a player.

pub fn as_gadget(&self) -> Option<&Gadget>[src]

Accesses the inner Gadget struct, if available.

pub fn is_gadget(&self) -> bool[src]

Determines whether this AgentKind contains a gadget.

pub fn as_character(&self) -> Option<&Character>[src]

Accesses the inner Character struct, if available.

pub fn is_character(&self) -> bool[src]

Determines whether this AgentKind contains a character.

Trait Implementations

impl Clone for AgentKind[src]

impl Debug for AgentKind[src]

impl Eq for AgentKind[src]

impl Hash for AgentKind[src]

impl PartialEq<AgentKind> for AgentKind[src]

impl StructuralEq for AgentKind[src]

impl StructuralPartialEq for AgentKind[src]

impl<'_> TryFrom<&'_ Agent> for AgentKind[src]

type Error = EvtcError

The type returned in the event of a conversion error.

fn try_from(raw_agent: &Agent) -> Result<Self, Self::Error>[src]

Extract the correct AgentKind from the given raw agent.

This automatically discerns between player, gadget and characters.

Note that in most cases, you probably want to use Agent::try_from or even process instead of this function.

impl TryFrom<Agent> for AgentKind[src]

type Error = EvtcError

The type returned in the event of a conversion error.

fn try_from(raw_agent: Agent) -> Result<Self, Self::Error>[src]

Convenience method to avoid manual borrowing.

Note that this conversion will consume the agent, so if you plan on re-using it, use the TryFrom<&raw::Agent> implementation that works with a reference.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.