pub trait BorrowComponent {
// Required methods
fn borrow_column(&self, ci: usize) -> BorrowResult<RawGetter>;
fn borrow_column_mut(&mut self, ci: usize) -> BorrowResult<RawGetter>;
unsafe fn get_column(&self, ci: usize) -> Option<NonNull<u8>>;
}Expand description
A trait for borrowing a component column from an entity container.
See ContainEntity for more information.
Required Methods§
Sourcefn borrow_column(&self, ci: usize) -> BorrowResult<RawGetter>
fn borrow_column(&self, ci: usize) -> BorrowResult<RawGetter>
Borrows component column for the given column index.
If borrow is successful, returns RawGetter of the component column.
Otherwise, returns BorrowError.
§Examples
use my_ecs::prelude::*;
use std::{hash::RandomState, any::TypeId};
#[derive(Component)]
struct Ca;
let mut cont: SparseSet<RandomState> = SparseSet::new();
cont.add_column(tinfo!(Ca));
let col_idx = cont.get_column_index(&TypeId::of::<Ca>()).unwrap();
let getter = cont.borrow_column(col_idx).unwrap();Sourcefn borrow_column_mut(&mut self, ci: usize) -> BorrowResult<RawGetter>
fn borrow_column_mut(&mut self, ci: usize) -> BorrowResult<RawGetter>
Borrows component column mutably for the given column index.
If borrow is successful, returns RawGetter of the component column.
Otherwise, returns BorrowError.
§Examples
use my_ecs::prelude::*;
use std::{hash::RandomState, any::TypeId};
#[derive(Component)]
struct Ca;
let mut cont: SparseSet<RandomState> = SparseSet::new();
cont.add_column(tinfo!(Ca));
let col_idx = cont.get_column_index(&TypeId::of::<Ca>()).unwrap();
let getter = cont.borrow_column_mut(col_idx).unwrap();