Skip to main content

Crate manasight_parser

Crate manasight_parser 

Source
Expand description

MTG Arena log file parser.

This library crate reads Arena’s Player.log, parses raw log entries into typed game events, and distributes them via an async broadcast channel. It is designed to run on the caller’s Tokio runtime — it does not initialize its own runtime or logger.

§Quick start (async, desktop)

Requires the tailer feature (enabled by default):

use std::path::Path;
use manasight_parser::MtgaEventStream;

let (stream, mut subscriber) = MtgaEventStream::start(Path::new("Player.log")).await?;

while let Some(event) = subscriber.recv().await {
    println!("got event: {event:?}");
}

§Quick start (sync, WASM)

With --no-default-features --features brace_depth_flush (no tailer), only the pure-sync subset of the crate is available:

use manasight_parser::parse_whole_log;

let input = ""; // replace with actual Player.log content
let events = parse_whole_log(input);
println!("parsed {} events", events.len());

§Architecture

Player.log → File Tailer → Entry Buffer → Router → Parsers → Event Bus
  • log module: file discovery, polling tailer, entry accumulation, timestamps
  • router: dispatches raw entries to the correct category parser
  • parsers: one sub-module per event category
  • events: public event type enums/structs (the parser’s output contract)
  • event_bus: tokio::broadcast channel for fan-out to subscribers (requires tailer feature)
  • stream: public entry point (MtgaEventStream) (requires tailer feature)

Re-exports§

pub use event_bus::Subscriber;
pub use events::ClientActionEvent;
pub use events::DeckCollectionEvent;
pub use events::DeckSubmissionEvent;
pub use events::DetailedLoggingStatusEvent;
pub use events::DraftBotEvent;
pub use events::DraftCompleteEvent;
pub use events::DraftHumanEvent;
pub use events::EventLifecycleEvent;
pub use events::EventMetadata;
pub use events::GameEvent;
pub use events::GameResultEvent;
pub use events::GameStateEvent;
pub use events::InventoryEvent;
pub use events::LogFileRotatedEvent;
pub use events::MatchStateEvent;
pub use events::PerformanceClass;
pub use events::RankEvent;
pub use events::SessionEvent;
pub use events::TruncationEvent;
pub use sanitize::scrub_raw_log;
pub use sanitize::scrub_raw_log_with;
pub use sanitize::ScrubOptions;
pub use stream::MtgaEventStream;
pub use stream::StreamError;
pub use util::compress_log;
pub use util::content_hash;

Modules§

event_bus
Async broadcast channel for distributing parsed events to subscribers.
events
Public event type enums and structs for parsed MTG Arena log events.
log
Raw log file reading: discovery, tailing, entry parsing, and timestamps.
parsers
Category-specific parsers — one module per event category.
router
Raw log entry to parser dispatch routing.
sanitize
Privacy scrubber for raw MTGA log text.
stream
Public entry point for streaming typed events from an MTG Arena log file.
util
Shared utility functions for the parser crate.

Functions§

parse_whole_log
Parses an entire MTG Arena Player.log string into a Vec of GameEvents.