
# Objective - A preparation for the 'system as entities' - The current system has a series of states such as `is_send`, `is_exclusive`, `has_defered`, As `system as entites` landed, it may have more states. Using Bitflags to unify all states is a more concise and performant approach ## Solution - Using Bitflags to unify system state.
44 lines
673 B
Markdown
44 lines
673 B
Markdown
---
|
|
title: Unified system state flag
|
|
pull_requests: [19506]
|
|
---
|
|
|
|
Now the system have a unified `SystemStateFlags` to represent its different states.
|
|
|
|
If your code previously looked like this:
|
|
|
|
```rust
|
|
impl System for MyCustomSystem {
|
|
// ...
|
|
|
|
fn is_send(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
fn is_exclusive(&self) -> bool {
|
|
true
|
|
}
|
|
|
|
fn has_deferred(&self) -> bool {
|
|
false
|
|
}
|
|
|
|
// ....
|
|
}
|
|
```
|
|
|
|
You should migrate it to:
|
|
|
|
```rust
|
|
impl System for MyCustomSystem{
|
|
// ...
|
|
|
|
fn flags(&self) -> SystemStateFlags {
|
|
// non-send , exclusive , no deferred
|
|
SystemStateFlags::NON_SEND | SystemStateFlags::EXCLUSIVE
|
|
}
|
|
|
|
// ...
|
|
}
|
|
```
|