pub struct StateFlags(pub u32);Expand description
State flags bitmask helper for inventory items.
Items in Borderlands 4 saves have a state_flags field that encodes
various properties using a bitmask. This struct provides a type-safe
way to work with these flags without knowing the bit positions.
§Example
use bl4::StateFlags;
// Create flags for a backpack item marked as favorite
let flags = StateFlags::backpack().with_favorite();
// Create flags for an equipped item
let equipped = StateFlags::equipped();
// Query flags
assert!(flags.is_favorite());
assert!(flags.is_in_backpack());Tuple Fields§
§0: u32Implementations§
Source§impl StateFlags
impl StateFlags
Sourcepub fn with_favorite(self) -> Self
pub fn with_favorite(self) -> Self
Set the favorite label (clears other labels).
Sourcepub fn with_label1(self) -> Self
pub fn with_label1(self) -> Self
Set label 1 (clears other labels).
Sourcepub fn with_label2(self) -> Self
pub fn with_label2(self) -> Self
Set label 2 (clears other labels).
Sourcepub fn with_label3(self) -> Self
pub fn with_label3(self) -> Self
Set label 3 (clears other labels).
Sourcepub fn with_label4(self) -> Self
pub fn with_label4(self) -> Self
Set label 4 (clears other labels).
Sourcepub fn with_no_label(self) -> Self
pub fn with_no_label(self) -> Self
Clear all labels (favorite, junk, 1-4).
Sourcepub fn is_favorite(&self) -> bool
pub fn is_favorite(&self) -> bool
Check if the favorite flag is set.
Sourcepub fn has_label1(&self) -> bool
pub fn has_label1(&self) -> bool
Check if label 1 is set.
Sourcepub fn has_label2(&self) -> bool
pub fn has_label2(&self) -> bool
Check if label 2 is set.
Sourcepub fn has_label3(&self) -> bool
pub fn has_label3(&self) -> bool
Check if label 3 is set.
Sourcepub fn has_label4(&self) -> bool
pub fn has_label4(&self) -> bool
Check if label 4 is set.
Sourcepub fn is_in_backpack(&self) -> bool
pub fn is_in_backpack(&self) -> bool
Check if the item is in backpack (not equipped).
Sourcepub fn is_equipped(&self) -> bool
pub fn is_equipped(&self) -> bool
Check if the item is equipped (not in backpack only).
Sourcepub fn set_favorite(&mut self, value: bool)
pub fn set_favorite(&mut self, value: bool)
Set favorite label (clears other labels) or clear it.
Sourcepub fn set_label1(&mut self, value: bool)
pub fn set_label1(&mut self, value: bool)
Set label 1 (clears other labels) or clear it.
Sourcepub fn set_label2(&mut self, value: bool)
pub fn set_label2(&mut self, value: bool)
Set label 2 (clears other labels) or clear it.
Sourcepub fn set_label3(&mut self, value: bool)
pub fn set_label3(&mut self, value: bool)
Set label 3 (clears other labels) or clear it.
Sourcepub fn set_label4(&mut self, value: bool)
pub fn set_label4(&mut self, value: bool)
Set label 4 (clears other labels) or clear it.
Sourcepub fn clear_labels(&mut self)
pub fn clear_labels(&mut self)
Clear all labels.
Sourcepub fn to_equipped(self) -> Self
pub fn to_equipped(self) -> Self
Convert to equipped flags (clear backpack bit).
Sourcepub fn to_backpack(self) -> Self
pub fn to_backpack(self) -> Self
Convert to backpack flags (set backpack bit).
Trait Implementations§
Source§impl Clone for StateFlags
impl Clone for StateFlags
Source§fn clone(&self) -> StateFlags
fn clone(&self) -> StateFlags
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StateFlags
impl Debug for StateFlags
Source§impl Default for StateFlags
impl Default for StateFlags
Source§fn default() -> StateFlags
fn default() -> StateFlags
Source§impl From<StateFlags> for u32
impl From<StateFlags> for u32
Source§fn from(f: StateFlags) -> Self
fn from(f: StateFlags) -> Self
Source§impl From<u32> for StateFlags
impl From<u32> for StateFlags
Source§impl PartialEq for StateFlags
impl PartialEq for StateFlags
impl Copy for StateFlags
impl Eq for StateFlags
impl StructuralPartialEq for StateFlags
Auto Trait Implementations§
impl Freeze for StateFlags
impl RefUnwindSafe for StateFlags
impl Send for StateFlags
impl Sync for StateFlags
impl Unpin for StateFlags
impl UnwindSafe for StateFlags
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.