Skip to main content

Address

Trait Address 

Source
pub trait Address:
    VariantArray
    + Clone
    + Send
    + Sync
    + Sized
    + 'static {
    // Required methods
    fn vector_field_or_scalar(&self) -> (Self, VectorField);
    fn to_u16(&self) -> u16;
    fn name(&self) -> &'static str;
    fn type_(&self) -> Type;

    // Provided methods
    fn fields(&self) -> Option<[(Self, VectorField); 3]> { ... }
    fn from_u16_typed(val: u16, ty: Type) -> Option<Self> { ... }
    fn from_name(name: &str) -> Option<Self> { ... }
}
Expand description

Trait for global or field addresses

Required Methods§

Source

fn vector_field_or_scalar(&self) -> (Self, VectorField)

For addresses that are a component of a vector, this returns the address of the vector itself along with the field of the vector that it relates to (x, y, or z). For other fields, this is a no-op.

Source

fn to_u16(&self) -> u16

Get the offset to this global.

Source

fn name(&self) -> &'static str

Get the name of this global.

Source

fn type_(&self) -> Type

Get the type of values at this address

Provided Methods§

Source

fn fields(&self) -> Option<[(Self, VectorField); 3]>

For vector globals, returns the component fields. For scalars, just returns self.

Source

fn from_u16_typed(val: u16, ty: Type) -> Option<Self>

Convert a raw offset into the relevant FieldAddr, given the type. Certain field offsets are specified to overlap in the progdefs.qc in order to have quick access to fields of vectors, and this can distinguish between vector foo and float foo_x.

Source

fn from_name(name: &str) -> Option<Self>

Given a name, get the global address the name corresponds to.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§