Skip to main content

FieldValue

Enum FieldValue 

Source
pub enum FieldValue {
Show 14 variants Boolean(bool), String(String), Float(f32), Vector2D([f32; 2]), Vector3D([f32; 3]), Vector4D([f32; 4]), Signed8(i8), Signed16(i16), Signed32(i32), Signed64(i64), Unsigned8(u8), Unsigned16(u16), Unsigned32(u32), Unsigned64(u64),
}
Expand description

Value type for entity properties.

This enum represents all possible types that can be stored in entity properties. Use TryInto to convert to Rust types, or use the property! macro for convenient access.

§Variants

  • Numeric types: i8, i16, i32, i64, u8, u16, u32, u64
  • Floating point: f32
  • Text: String
  • Vectors: 2D, 3D, and 4D float arrays
  • Boolean: bool

§Examples

§Manual conversion

use source2_demo::prelude::*;

let field_value = entity.get_property_by_name("m_iHealth")?;
let health: i32 = field_value.try_into()?;
println!("Health: {}", health);

§Using property! macro

use source2_demo::prelude::*;

// Type is inferred
let health: i32 = property!(entity, "m_iHealth");

Variants§

§

Boolean(bool)

Boolean value

§

String(String)

String value

§

Float(f32)

32-bit floating point value

§

Vector2D([f32; 2])

2D vector

§

Vector3D([f32; 3])

3D vector

§

Vector4D([f32; 4])

4D vector

§

Signed8(i8)

Signed 8-bit integer

§

Signed16(i16)

Signed 16-bit integer

§

Signed32(i32)

Signed 32-bit integer

§

Signed64(i64)

Signed 64-bit integer

§

Unsigned8(u8)

Unsigned 8-bit integer

§

Unsigned16(u16)

Unsigned 16-bit integer

§

Unsigned32(u32)

Unsigned 32-bit integer

§

Unsigned64(u64)

Unsigned 64-bit integer

Implementations§

Source§

impl FieldValue

Source

pub fn string(&self) -> String

Return the inner string. Panics if this is not a FieldValue::String.

Source

pub fn bool(&self) -> bool

Return the inner boolean. Panics if this is not a FieldValue::Boolean.

Source

pub fn f32(&self) -> f32

Return the inner f32. Panics if this is not a FieldValue::Float.

Source

pub fn vec2(&self) -> &[f32; 2]

Return a reference to a 2D vector ([f32; 2]). Panics if the value is not Vector2D.

Source

pub fn vec3(&self) -> &[f32; 3]

Return a reference to a 3D vector ([f32; 3]). Panics if the value is not Vector3D.

Source

pub fn vec4(&self) -> &[f32; 4]

Return a reference to a 4D vector ([f32; 4]). Panics if the value is not Vector4D.

Source

pub fn i8(&self) -> i8

Read as signed 8-bit integer. Panics if value is not Signed8.

Source

pub fn i16(&self) -> i16

Read as signed 16-bit integer. Panics if value is not Signed16.

Source

pub fn i32(&self) -> i32

Read as signed 32-bit integer. Panics if value is not Signed32.

Source

pub fn i64(&self) -> i64

Read as signed 64-bit integer. Panics if value is not Signed64.

Source

pub fn u8(&self) -> u8

Read as unsigned 8-bit integer. Panics if value is not Unsigned8.

Source

pub fn u16(&self) -> u16

Read as unsigned 16-bit integer. Panics if value is not Unsigned16.

Source

pub fn u32(&self) -> u32

Read as unsigned 32-bit integer. Panics if value is not Unsigned32.

Source

pub fn u64(&self) -> u64

Read as unsigned 64-bit integer. Panics if value is not Unsigned64.

Source

pub fn usize(&self) -> usize

Read as usize. Accepts Unsigned32 or Unsigned64 and casts to usize. Panics for other variants.

Trait Implementations§

Source§

impl Clone for FieldValue

Source§

fn clone(&self) -> FieldValue

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FieldValue

Source§

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

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

impl Display for FieldValue

Source§

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

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

impl IntoFieldValue for FieldValue

Source§

fn into_field_value(self) -> FieldValue

Converts this value into a FieldValue.
Source§

impl PartialEq for FieldValue

Source§

fn eq(&self, other: &FieldValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 TryInto<[f32; 2]> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 2], FieldValueError>

Performs the conversion.
Source§

impl TryInto<[f32; 2]> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 2], FieldValueError>

Performs the conversion.
Source§

impl TryInto<[f32; 3]> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 3], FieldValueError>

Performs the conversion.
Source§

impl TryInto<[f32; 3]> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 3], FieldValueError>

Performs the conversion.
Source§

impl TryInto<[f32; 4]> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 4], FieldValueError>

Performs the conversion.
Source§

impl TryInto<[f32; 4]> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<[f32; 4], FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32)> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32)> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32, f32)> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32, f32)> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32, f32, f32)> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32, f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<(f32, f32, f32, f32)> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<(f32, f32, f32, f32), FieldValueError>

Performs the conversion.
Source§

impl TryInto<String> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<String, FieldValueError>

Performs the conversion.
Source§

impl TryInto<String> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<String, FieldValueError>

Performs the conversion.
Source§

impl TryInto<Vec<f32>> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<Vec<f32>, FieldValueError>

Performs the conversion.
Source§

impl TryInto<Vec<f32>> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<Vec<f32>, FieldValueError>

Performs the conversion.
Source§

impl TryInto<bool> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<bool, FieldValueError>

Performs the conversion.
Source§

impl TryInto<bool> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<bool, FieldValueError>

Performs the conversion.
Source§

impl TryInto<f32> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<f32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<f32> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<f32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i128> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i128, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i128> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i128, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i16> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i16, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i16> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i16, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i32> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i32> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i64> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i64, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i64> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i64, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i8> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i8, FieldValueError>

Performs the conversion.
Source§

impl TryInto<i8> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<i8, FieldValueError>

Performs the conversion.
Source§

impl TryInto<isize> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<isize, FieldValueError>

Performs the conversion.
Source§

impl TryInto<isize> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<isize, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u128> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u128, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u128> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u128, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u16> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u16, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u16> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u16, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u32> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u32> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u32, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u64> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u64, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u64> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u64, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u8> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u8, FieldValueError>

Performs the conversion.
Source§

impl TryInto<u8> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<u8, FieldValueError>

Performs the conversion.
Source§

impl TryInto<usize> for &FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<usize, FieldValueError>

Performs the conversion.
Source§

impl TryInto<usize> for FieldValue

Source§

type Error = FieldValueError

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

fn try_into(self) -> Result<usize, FieldValueError>

Performs the conversion.
Source§

impl StructuralPartialEq for FieldValue

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> 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> FieldRewriteResult for T
where T: IntoFieldValue,

Source§

fn into_field_rewrite_result(self) -> Option<FieldValue>

Converts this handler result into an optional FieldValue.
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.