Skip to main content

WeaponError

Enum WeaponError 

Source
pub enum WeaponError {
Show 16 variants Attribute(AttributeError), CreationFailed, CreationFailedNative(ItemGenerationError), DifferentOwner, Interface(InterfaceError), InvalidClip { clip: c_int, max: c_int, }, MarkedForDeletion, MissingOrigin, NetProp(NetPropError), NoClip, NotTfPlayer, NotWeapon, Rejected, SlotOccupied, UnsupportedLayout, WrongSlot,
}
Available on crate feature tf2 only.
Expand description

Why a weapon or inventory operation failed.

Variants§

§

Attribute(AttributeError)

Reading the weapon’s attributes failed, or PlayerWeapons::give_item_with could not apply its attributes.

§

CreationFailed

GiveNamedItem returned no entity (for example, because the player already has that weapon type), or a classname override produced an entity of another classname.

§

CreationFailedNative(ItemGenerationError)

Native item generation, used by give_item and its variants, failed, as the ItemGenerationError tells.

§

DifferentOwner

The weapon’s combat owner is not this player: another entity owns it, or PlayerWeapons::detach was given an unowned weapon.

§

Interface(InterfaceError)

A required engine interface is unavailable.

§

InvalidClip

Weapon::set_clip was given a count outside 0 to the weapon’s max.

Fields

§clip: c_int

The count given.

§max: c_int

The weapon’s max clip.

§

MarkedForDeletion

The player or weapon is already marked for deletion.

§

MissingOrigin

The player’s position, needed to spawn an economy item, is unavailable.

§

NetProp(NetPropError)

The player’s weapons, which PlayerWeapons::active and PlayerWeapons::all read from its networked variables, could not be read.

§

NoClip

The weapon has no clip, as melee weapons and miniguns, or counts its shots in energy.

§

NotTfPlayer

The entity is not a TF2 player, or the server does not run TF2.

§

NotWeapon

The entity is not a TF2 weapon (for example, it is a cosmetic), or the server does not run TF2.

§

Rejected

The game did not complete a detach or equip: RemovePlayerItem refused the weapon, or it did not end up in its slot with this player as its combat owner. A refused equip may still have set the weapon’s owner.

§

SlotOccupied

The weapon’s native slot already holds another weapon.

§

UnsupportedLayout

The weapon’s datamap lacks a usable m_hOwner field, or, for Weapon::clip and Weapon::set_clip, a usable m_iClip1 field, or, for Weapon::definition, its networked variables do not place its item definition index where the SDK’s layout does.

§

WrongSlot

A replacement’s native slot is not the requested slot, or a new weapon’s slot number is outside 0..=255, the range creation tracks.

Trait Implementations§

Source§

impl Debug for WeaponError

Source§

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

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

impl Display for WeaponError

Source§

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

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

impl Error for WeaponError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<AttributeError> for WeaponError

Source§

fn from(source: AttributeError) -> Self

Converts to this type from the input type.
Source§

impl From<InterfaceError> for WeaponError

Source§

fn from(source: InterfaceError) -> Self

Converts to this type from the input type.
Source§

impl From<ItemGenerationError> for WeaponError

Source§

fn from(source: ItemGenerationError) -> Self

Converts to this type from the input type.
Source§

impl From<NetPropError> for WeaponError

Source§

fn from(source: NetPropError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.