#[non_exhaustive]pub struct EventFlags { /* private fields */ }Expand description
A generic, string-keyed event flag system.
Stores boolean flags keyed by string name. This is the foundation for
game-event tracking (story progression, item pickups, trainer defeats)
in any JRPG. The struct is #[non_exhaustive] to allow game-specific
extensions in downstream crates.
§Design
- Flags are stored as
HashMap<String, bool>— one entry per flag name. - The string API (
get_flag,set_flag,remove_flag) works with any flag name, enabling game-specific typed wrappers. - All methods are pure data manipulation — no I/O, no platform code.
§Example
ⓘ
let mut flags = EventFlags::new();
flags.set_flag("player_has_sword", true);
assert!(flags.get_flag("player_has_sword"));Implementations§
Source§impl EventFlags
impl EventFlags
Sourcepub fn get_flag(&self, name: &str) -> bool
pub fn get_flag(&self, name: &str) -> bool
Returns the value of a named flag, or false if unset.
Sourcepub fn remove_flag(&mut self, name: &str)
pub fn remove_flag(&mut self, name: &str)
Removes a named flag entirely.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &bool)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &bool)>
Returns an iterator over all (name, value) pairs.
Sourcepub fn as_hashmap(&self) -> &HashMap<String, bool>
pub fn as_hashmap(&self) -> &HashMap<String, bool>
Returns a shared reference to the underlying HashMap.
Sourcepub fn as_hashmap_mut(&mut self) -> &mut HashMap<String, bool>
pub fn as_hashmap_mut(&mut self) -> &mut HashMap<String, bool>
Returns a mutable reference to the underlying HashMap.
Sourcepub fn merge_from(&mut self, other: &HashMap<String, bool>)
pub fn merge_from(&mut self, other: &HashMap<String, bool>)
Merges entries from another HashMap into this flag set.
Existing keys are overwritten.
Sourcepub fn to_hashmap(&self) -> HashMap<String, bool>
pub fn to_hashmap(&self) -> HashMap<String, bool>
Clones the underlying HashMap for external use.
Sourcepub fn from_hashmap(map: &HashMap<String, bool>) -> Self
pub fn from_hashmap(map: &HashMap<String, bool>) -> Self
Creates an EventFlags from an existing HashMap.
Trait Implementations§
Source§impl Clone for EventFlags
impl Clone for EventFlags
Source§fn clone(&self) -> EventFlags
fn clone(&self) -> EventFlags
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for EventFlags
impl Debug for EventFlags
Auto Trait Implementations§
impl Freeze for EventFlags
impl RefUnwindSafe for EventFlags
impl Send for EventFlags
impl Sync for EventFlags
impl Unpin for EventFlags
impl UnsafeUnpin for EventFlags
impl UnwindSafe for EventFlags
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more