Skip to main content

rewrite_field

Attribute Macro rewrite_field 

Source
#[rewrite_field]
Expand description

Replaces decoded entity field values with class and field filters.

§Attribute Arguments

  • class = ... is required.
  • field = ... is optional.

Both filters accept an exact string literal or the exact, starts_with, ends_with, contains, any, all, and not predicates.

Field-specific handlers may use typed values such as u64, bool, or String. Class-only handlers must use FieldValue or &FieldValue because there is no field predicate to determine one concrete value type.

§Handler Parameters

A handler must receive one field value parameter. Field-specific handlers support &str, String, &String, bool, f32, i8, i16, i32, i64, u8, u16, u32, u64, [f32; 2], [f32; 3], [f32; 4], FieldValue, and &FieldValue. Class-only handlers must use FieldValue or &FieldValue.

A handler can also receive any of these optional parameters:

  • ctx: &Context
  • event: EntityEvents
  • entity: &Entity
  • field_name: &str

Parameters can appear in any order except that field_name: &str must come before the field value parameter. This matters because &str can itself be the field value type.

§Return Values

Return a replacement value directly to always rewrite the field. Return Option<T> to rewrite with Some(value) or leave the field unchanged with None. The replacement must convert into FieldValue.

§Examples

#[rewrite_field(class = "CDOTA_PlayerResource", field = ends_with("m_iPlayerSteamID"))]
fn remove_steam_id(&mut self, _value: u64) -> u64 {
    0
}