pub trait CellConvert: Sized {
// Required methods
fn from_cell(raw: i32) -> Self;
fn into_cell(self) -> i32;
}Expand description
Conversion between Rust and an AMX cell (i32) without needing &Amx.
Difference vs AmxCell: this trait operates on standalone values, ideal
for bulk operations over Buffer (each element is an independent cell).
| Trait | When to use | Needs &Amx? |
|---|---|---|
AmxCell | Argument of a #[native] | Yes (for complex types) |
CellConvert | Element of a Buffer | No |
Rarely needs to be imported/implemented directly — Buffer::get_as and
Buffer::set_as already consume this trait.
§Example
fn scale_floats(buf: &mut Buffer, factor: f32) {
for i in 0..buf.len() {
if let Some(v) = buf.get_as::<f32>(i) {
buf.set_as(i, v * factor);
}
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".