ItemSerial

Struct ItemSerial 

Source
pub struct ItemSerial {
    pub original: String,
    pub raw_bytes: Vec<u8>,
    pub item_type: char,
    pub tokens: Vec<Token>,
    pub manufacturer: Option<u64>,
    pub level: Option<u64>,
    pub raw_level: Option<u64>,
    pub seed: Option<u64>,
    pub elements: Vec<Element>,
    pub rarity: Option<Rarity>,
}
Expand description

Decoded item serial information

Fields§

§original: String

Original ASCII85-encoded serial

§raw_bytes: Vec<u8>

Raw decoded bytes

§item_type: char

Item type character (r=weapon, e=equipment, etc.)

§tokens: Vec<Token>

Parsed tokens from bitstream

§manufacturer: Option<u64>

Decoded fields (extracted from tokens) For VarInt-first format: Combined manufacturer + weapon type ID

§level: Option<u64>

Item level (fourth VarInt for VarInt-first format), capped at 50

§raw_level: Option<u64>

Raw decoded level before capping (if > 50, our decoding may be wrong)

§seed: Option<u64>

Random seed for stat rolls (second VarInt after first separator)

§elements: Vec<Element>

Detected elements (from Part tokens with index 128-142)

§rarity: Option<Rarity>

Detected rarity (from level code or equipment VarBit)

Implementations§

Source§

impl ItemSerial

Source

pub fn decode(serial: &str) -> Result<Self, SerialError>

Decode a Borderlands 4 item serial

Format: @Ug<type><base85_data> Example: @Ugr$ZCm/&tH!t{KgK/Shxu>k

Source

pub fn encode(&self) -> String

Encode this item serial back to a Base85 string

This encodes the current tokens back to a serial string. Useful for modifying an item and getting the new serial.

Source

pub fn encode_from_tokens(&self) -> String

Encode with modified tokens (experimental) This attempts to encode tokens back to bytes, but may not preserve all original data like item type encoding.

Source

pub fn with_tokens(&self, tokens: Vec<Token>) -> Self

Create a new ItemSerial with modified tokens

Source

pub fn hex_dump(&self) -> String

Display hex dump of raw bytes

Source

pub fn format_tokens(&self) -> String

Format tokens as human-readable string Example: 134, 0, 8, 196| 4, 2379|| {8} {4} {2} {8:3} {34}

Source

pub fn item_type_description(&self) -> &'static str

Get item type description

Source

pub fn manufacturer_name(&self) -> Option<&'static str>

Get manufacturer name if known

Source

pub fn element_names(&self) -> Option<String>

Get element names as a formatted string Returns None if no elements detected, otherwise returns comma-separated list

Source

pub fn rarity_name(&self) -> Option<&'static str>

Get rarity name Returns None if rarity not detected

Source

pub fn weapon_info(&self) -> Option<(&'static str, &'static str)>

Get weapon info (manufacturer, weapon type) for VarInt-first format serials

Returns None for VarBit-first formats or if the ID is unknown.

Source

pub fn part_group_id(&self) -> Option<i64>

Extract Part Group ID (category) from the serial

Uses the format’s category_divisor to extract category from first VarBit. Returns None if this format doesn’t use VarBit categories.

Source

pub fn parts_category(&self) -> Option<i64>

Get the parts database category for this item

For VarBit-first items (shields, etc), uses the extracted category. For VarInt-first items (weapons), converts the serial ID to parts DB category.

Source

pub fn parts(&self) -> Vec<(u64, Vec<u64>)>

Get all Part tokens from this serial Returns (index, values) pairs for each Part token

Source

pub fn detailed_dump(&self) -> String

Display detailed byte-by-byte breakdown

Trait Implementations§

Source§

impl Clone for ItemSerial

Source§

fn clone(&self) -> ItemSerial

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 ItemSerial

Source§

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

Formats the value using the given formatter. Read more

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<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.