pub enum FieldValue {
}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
impl FieldValue
Sourcepub fn string(&self) -> String
pub fn string(&self) -> String
Return the inner string. Panics if this is not a FieldValue::String.
Sourcepub fn bool(&self) -> bool
pub fn bool(&self) -> bool
Return the inner boolean. Panics if this is not a FieldValue::Boolean.
Sourcepub fn vec2(&self) -> &[f32; 2]
pub fn vec2(&self) -> &[f32; 2]
Return a reference to a 2D vector ([f32; 2]). Panics if the value is not
Vector2D.
Sourcepub fn vec3(&self) -> &[f32; 3]
pub fn vec3(&self) -> &[f32; 3]
Return a reference to a 3D vector ([f32; 3]). Panics if the value is not
Vector3D.
Trait Implementations§
Source§impl Clone for FieldValue
impl Clone for FieldValue
Source§fn clone(&self) -> FieldValue
fn clone(&self) -> FieldValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FieldValue
impl Debug for FieldValue
Source§impl Display for FieldValue
impl Display for FieldValue
Source§impl IntoFieldValue for FieldValue
impl IntoFieldValue for FieldValue
Source§fn into_field_value(self) -> FieldValue
fn into_field_value(self) -> FieldValue
FieldValue.Source§impl PartialEq for FieldValue
impl PartialEq for FieldValue
Source§fn eq(&self, other: &FieldValue) -> bool
fn eq(&self, other: &FieldValue) -> bool
self and other values to be equal, and is used by ==.Source§impl TryInto<String> for &FieldValue
impl TryInto<String> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<String> for FieldValue
impl TryInto<String> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<bool> for &FieldValue
impl TryInto<bool> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<bool> for FieldValue
impl TryInto<bool> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<f32> for &FieldValue
impl TryInto<f32> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<f32> for FieldValue
impl TryInto<f32> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i128> for &FieldValue
impl TryInto<i128> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i128> for FieldValue
impl TryInto<i128> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i16> for &FieldValue
impl TryInto<i16> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i16> for FieldValue
impl TryInto<i16> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i32> for &FieldValue
impl TryInto<i32> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i32> for FieldValue
impl TryInto<i32> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i64> for &FieldValue
impl TryInto<i64> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i64> for FieldValue
impl TryInto<i64> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i8> for &FieldValue
impl TryInto<i8> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<i8> for FieldValue
impl TryInto<i8> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<isize> for &FieldValue
impl TryInto<isize> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<isize> for FieldValue
impl TryInto<isize> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u128> for &FieldValue
impl TryInto<u128> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u128> for FieldValue
impl TryInto<u128> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u16> for &FieldValue
impl TryInto<u16> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u16> for FieldValue
impl TryInto<u16> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u32> for &FieldValue
impl TryInto<u32> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u32> for FieldValue
impl TryInto<u32> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u64> for &FieldValue
impl TryInto<u64> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u64> for FieldValue
impl TryInto<u64> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u8> for &FieldValue
impl TryInto<u8> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<u8> for FieldValue
impl TryInto<u8> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<usize> for &FieldValue
impl TryInto<usize> for &FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
Source§impl TryInto<usize> for FieldValue
impl TryInto<usize> for FieldValue
Source§type Error = FieldValueError
type Error = FieldValueError
impl StructuralPartialEq for FieldValue
Auto Trait Implementations§
impl Freeze for FieldValue
impl RefUnwindSafe for FieldValue
impl Send for FieldValue
impl Sync for FieldValue
impl Unpin for FieldValue
impl UnsafeUnpin for FieldValue
impl UnwindSafe for FieldValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FieldRewriteResult for Twhere
T: IntoFieldValue,
impl<T> FieldRewriteResult for Twhere
T: IntoFieldValue,
Source§fn into_field_rewrite_result(self) -> Option<FieldValue>
fn into_field_rewrite_result(self) -> Option<FieldValue>
FieldValue.