Skip to main content

GmAccess

Trait GmAccess 

Source
pub trait GmAccess {
    // Required methods
    fn field_id(name: &str) -> Option<u32>
       where Self: Sized;
    fn read_field(&self, id: u32) -> Option<FieldValue>;
    fn write_field(&mut self, id: u32, value: &FieldValue) -> bool;
}
Expand description

Generic, module-agnostic access to GlobalMemory fields by name or id.

This is the inverse of the ChangeTracker field table, and like it, it is auto-generated by the code generator — you don’t implement it by hand. It exists so that any consumer — the IDE, debuggers, name-keyed IPC, the autocore-seq sequencer — can read and write GM fields generically, without the framework knowing about those consumers. field_id is resolved once (off the hot path); read_field / write_field are O(1).

Required Methods§

Source

fn field_id(name: &str) -> Option<u32>
where Self: Sized,

Resolve a field name to a stable id. None if there is no such field.

Source

fn read_field(&self, id: u32) -> Option<FieldValue>

Read a field by id. None if the id is out of range.

Source

fn write_field(&mut self, id: u32, value: &FieldValue) -> bool

Write a field by id. Returns false if the id is unknown or the value is type-incompatible (e.g. text into a numeric field).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§