Parsed Elements
Reference of all ParsedElement variants from the game protocol parser.
Overview
ParsedElements are the structured output of the XML parser. Each variant represents a specific type of game data.
Text Elements
Text
Plain text content.
#![allow(unused)]
fn main() {
ParsedElement::Text(String)
}
Source: Untagged text between XML elements.
StyledText
Text with formatting.
#![allow(unused)]
fn main() {
ParsedElement::StyledText {
text: String,
bold: bool,
preset: Option<String>,
}
}
Source: <pushBold/>, <popBold/>, <preset id="..."/>
Room Elements
RoomName
Current room name.
#![allow(unused)]
fn main() {
ParsedElement::RoomName(String)
}
Source: <roomName>...</roomName>
RoomDesc
Room description text.
#![allow(unused)]
fn main() {
ParsedElement::RoomDesc(String)
}
Source: <roomDesc>...</roomDesc>
RoomObjects
Objects in the room.
#![allow(unused)]
fn main() {
ParsedElement::RoomObjects(String)
}
Source: <roomObjs>...</roomObjs>
RoomPlayers
Players in the room.
#![allow(unused)]
fn main() {
ParsedElement::RoomPlayers(String)
}
Source: <roomPlayers>...</roomPlayers>
RoomExits
Available exits.
#![allow(unused)]
fn main() {
ParsedElement::RoomExits(String)
}
Source: <roomExits>...</roomExits>
Vitals Elements
Vitals
Character vital statistics.
#![allow(unused)]
fn main() {
ParsedElement::Vitals {
health: Option<u8>,
mana: Option<u8>,
stamina: Option<u8>,
spirit: Option<u8>,
}
}
Source: <progressBar id="..." value="..."/>
Progress bar IDs:
health,manapoints,stamina,spiritencumlevel,mindState,nextLvlPB
Timing Elements
Roundtime
Action roundtime.
#![allow(unused)]
fn main() {
ParsedElement::Roundtime(u32)
}
Source: <roundTime value="..."/> or Roundtime: N sec
CastTime
Spell casting time.
#![allow(unused)]
fn main() {
ParsedElement::CastTime(u32)
}
Source: <castTime value="..."/>
Status Elements
Indicator
Status indicator change.
#![allow(unused)]
fn main() {
ParsedElement::Indicator {
id: String,
visible: bool,
}
}
Source: <indicator id="..." visible="y|n"/>
Common indicator IDs:
IconHIDDEN,IconSTUNNED,IconWEBBEDIconPRONE,IconKNEELING,IconSITTINGIconBLEEDING,IconPOISONED,IconDISEASEDIconINVISIBLE,IconDEAD
Stance
Combat stance.
#![allow(unused)]
fn main() {
ParsedElement::Stance(String)
}
Source: <stance id="..."/>
Values: offensive, forward, neutral, guarded, defensive
Navigation Elements
Compass
Available directions.
#![allow(unused)]
fn main() {
ParsedElement::Compass {
directions: Vec<String>,
}
}
Source: <compass><dir value="..."/>...</compass>
Direction values:
n,s,e,w(cardinal)ne,nw,se,sw(diagonal)up,down,out
Hand Elements
LeftHand
Item in left hand.
#![allow(unused)]
fn main() {
ParsedElement::LeftHand {
noun: String,
name: String,
exist: Option<String>,
}
}
Source: <left exist="..." noun="...">...</left>
RightHand
Item in right hand.
#![allow(unused)]
fn main() {
ParsedElement::RightHand {
noun: String,
name: String,
exist: Option<String>,
}
}
Source: <right exist="..." noun="...">...</right>
Spell
Prepared spell.
#![allow(unused)]
fn main() {
ParsedElement::Spell(String)
}
Source: <spell>...</spell>
Stream Elements
PushStream
Start of named stream.
#![allow(unused)]
fn main() {
ParsedElement::PushStream(String)
}
Source: <pushStream id="..."/>
PopStream
End of current stream.
#![allow(unused)]
fn main() {
ParsedElement::PopStream
}
Source: <popStream/>
StreamContent
Content within a stream.
#![allow(unused)]
fn main() {
ParsedElement::StreamContent {
stream: String,
content: String,
}
}
Prompt Elements
Prompt
Game prompt.
#![allow(unused)]
fn main() {
ParsedElement::Prompt {
text: String,
time: Option<String>,
}
}
Source: <prompt time="...">...</prompt>
Link Elements
Link
Clickable object link.
#![allow(unused)]
fn main() {
ParsedElement::Link {
exist: String,
noun: String,
text: String,
}
}
Source: <a exist="..." noun="...">...</a>
CommandLink
Clickable command link.
#![allow(unused)]
fn main() {
ParsedElement::CommandLink {
cmd: String,
text: String,
}
}
Source: <d cmd="...">...</d>
Combat Elements
Combat
Combat message.
#![allow(unused)]
fn main() {
ParsedElement::Combat {
text: String,
}
}
Source: Text within combat stream.
Damage
Damage dealt or received.
#![allow(unused)]
fn main() {
ParsedElement::Damage {
amount: u32,
target: Option<String>,
}
}
Container Elements
Container
Container contents.
#![allow(unused)]
fn main() {
ParsedElement::Container {
id: String,
name: String,
contents: Vec<ContainerItem>,
}
}
ContainerItem
Item within container.
#![allow(unused)]
fn main() {
ContainerItem {
exist: String,
noun: String,
name: String,
}
}
Spell Elements
ActiveSpell
Currently active spell.
#![allow(unused)]
fn main() {
ParsedElement::ActiveSpell {
name: String,
duration: Option<u32>,
}
}
Source: <spell>...</spell> with duration
SpellExpire
Spell expired notification.
#![allow(unused)]
fn main() {
ParsedElement::SpellExpire {
name: String,
}
}
System Elements
Mode
Game mode change.
#![allow(unused)]
fn main() {
ParsedElement::Mode {
mode: String,
}
}
Source: <mode id="..."/>
Output
Output configuration.
#![allow(unused)]
fn main() {
ParsedElement::Output {
class: String,
}
}
Source: <output class="..."/>
ClearStream
Clear stream content.
#![allow(unused)]
fn main() {
ParsedElement::ClearStream(String)
}
Source: <clearStream id="..."/>
Unknown Element
Unrecognized XML.
#![allow(unused)]
fn main() {
ParsedElement::Unknown {
tag: String,
content: String,
}
}
Preserves unhandled elements for debugging.
Element Processing
Elements are processed in order:
#![allow(unused)]
fn main() {
for element in parser.parse(input) {
match element {
ParsedElement::RoomName(name) => {
state.room.name = name;
}
ParsedElement::Vitals { health, .. } => {
if let Some(h) = health {
state.vitals.health = h;
}
}
// ...
}
}
}