StateFlags

Struct StateFlags 

Source
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: u32

Implementations§

Source§

impl StateFlags

Source

pub fn backpack() -> Self

Create flags for a backpack item (valid + in_backpack).

Source

pub fn equipped() -> Self

Create flags for an equipped item (valid only, no backpack bit).

Source

pub fn bank() -> Self

Create flags for a bank item (valid only).

Source

pub fn from_raw(bits: u32) -> Self

Create flags from a raw u32 value.

Source

pub fn to_raw(self) -> u32

Get the raw u32 value.

Source

pub fn with_favorite(self) -> Self

Set the favorite label (clears other labels).

Source

pub fn with_junk(self) -> Self

Set the junk label (clears other labels).

Source

pub fn with_label1(self) -> Self

Set label 1 (clears other labels).

Source

pub fn with_label2(self) -> Self

Set label 2 (clears other labels).

Source

pub fn with_label3(self) -> Self

Set label 3 (clears other labels).

Source

pub fn with_label4(self) -> Self

Set label 4 (clears other labels).

Source

pub fn with_no_label(self) -> Self

Clear all labels (favorite, junk, 1-4).

Source

pub fn is_favorite(&self) -> bool

Check if the favorite flag is set.

Source

pub fn is_junk(&self) -> bool

Check if the junk flag is set.

Source

pub fn has_label1(&self) -> bool

Check if label 1 is set.

Source

pub fn has_label2(&self) -> bool

Check if label 2 is set.

Source

pub fn has_label3(&self) -> bool

Check if label 3 is set.

Source

pub fn has_label4(&self) -> bool

Check if label 4 is set.

Source

pub fn is_in_backpack(&self) -> bool

Check if the item is in backpack (not equipped).

Source

pub fn is_equipped(&self) -> bool

Check if the item is equipped (not in backpack only).

Source

pub fn set_favorite(&mut self, value: bool)

Set favorite label (clears other labels) or clear it.

Source

pub fn set_junk(&mut self, value: bool)

Set junk label (clears other labels) or clear it.

Source

pub fn set_label1(&mut self, value: bool)

Set label 1 (clears other labels) or clear it.

Source

pub fn set_label2(&mut self, value: bool)

Set label 2 (clears other labels) or clear it.

Source

pub fn set_label3(&mut self, value: bool)

Set label 3 (clears other labels) or clear it.

Source

pub fn set_label4(&mut self, value: bool)

Set label 4 (clears other labels) or clear it.

Source

pub fn clear_labels(&mut self)

Clear all labels.

Source

pub fn to_equipped(self) -> Self

Convert to equipped flags (clear backpack bit).

Source

pub fn to_backpack(self) -> Self

Convert to backpack flags (set backpack bit).

Trait Implementations§

Source§

impl Clone for StateFlags

Source§

fn clone(&self) -> StateFlags

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StateFlags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for StateFlags

Source§

fn default() -> StateFlags

Returns the “default value” for a type. Read more
Source§

impl From<StateFlags> for u32

Source§

fn from(f: StateFlags) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for StateFlags

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for StateFlags

Source§

fn eq(&self, other: &StateFlags) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for StateFlags

Source§

impl Eq for StateFlags

Source§

impl StructuralPartialEq for StateFlags

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.