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: StringOriginal ASCII85-encoded serial
raw_bytes: Vec<u8>Raw decoded bytes
item_type: charItem 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
impl ItemSerial
Sourcepub fn decode(serial: &str) -> Result<Self, SerialError>
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
Sourcepub fn encode(&self) -> String
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.
Sourcepub fn encode_from_tokens(&self) -> String
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.
Sourcepub fn with_tokens(&self, tokens: Vec<Token>) -> Self
pub fn with_tokens(&self, tokens: Vec<Token>) -> Self
Create a new ItemSerial with modified tokens
Sourcepub fn format_tokens(&self) -> String
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}
Sourcepub fn item_type_description(&self) -> &'static str
pub fn item_type_description(&self) -> &'static str
Get item type description
Sourcepub fn manufacturer_name(&self) -> Option<&'static str>
pub fn manufacturer_name(&self) -> Option<&'static str>
Get manufacturer name if known
Sourcepub fn element_names(&self) -> Option<String>
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
Sourcepub fn rarity_name(&self) -> Option<&'static str>
pub fn rarity_name(&self) -> Option<&'static str>
Get rarity name Returns None if rarity not detected
Sourcepub fn weapon_info(&self) -> Option<(&'static str, &'static str)>
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.
Sourcepub fn part_group_id(&self) -> Option<i64>
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.
Sourcepub fn parts_category(&self) -> Option<i64>
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.
Sourcepub fn parts(&self) -> Vec<(u64, Vec<u64>)>
pub fn parts(&self) -> Vec<(u64, Vec<u64>)>
Get all Part tokens from this serial Returns (index, values) pairs for each Part token
Sourcepub fn detailed_dump(&self) -> String
pub fn detailed_dump(&self) -> String
Display detailed byte-by-byte breakdown
Trait Implementations§
Source§impl Clone for ItemSerial
impl Clone for ItemSerial
Source§fn clone(&self) -> ItemSerial
fn clone(&self) -> ItemSerial
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more