pub struct ParserBuilder<V: Version> { /* private fields */ }Implementations§
Source§impl<V: Version> ParserBuilder<V>
impl<V: Version> ParserBuilder<V>
Sourcepub fn new() -> ParserBuilder<V>
pub fn new() -> ParserBuilder<V>
Initialize with default options
Sourcepub fn build(self) -> Parser<V>
pub fn build(self) -> Parser<V>
Creates a new Parser by moving the internal ParserOptions and consuming self.
§Example
use faf_replay_parser::scfa::{replay_command, ReplayCommandId};
use faf_replay_parser::{ParserBuilder, SCFA};
use std::convert::TryFrom;
let parser = ParserBuilder::<SCFA>::new()
.commands(&[
ReplayCommandId::try_from(replay_command::ADVANCE).unwrap(),
ReplayCommandId::try_from(replay_command::VERIFY_CHECKSUM).unwrap(),
ReplayCommandId::try_from(replay_command::END_GAME).unwrap(),
])
.build();Sourcepub fn build_stream(self) -> StreamParser<V>
pub fn build_stream(self) -> StreamParser<V>
Like build but creates a new StreamParser.
Sourcepub fn build_clone(&self) -> Parser<V>
pub fn build_clone(&self) -> Parser<V>
Creates a new Parser by cloning the internal ParserOptions. Useful when constructing
many parsers with similar options.
Example
use faf_replay_parser::scfa::{replay_command, ReplayCommandId};
use faf_replay_parser::{ParserBuilder, SCFA};
use std::convert::TryFrom;
let mut builder = ParserBuilder::<SCFA>::new().commands(&[
ReplayCommandId::try_from(replay_command::ADVANCE).unwrap(),
ReplayCommandId::try_from(replay_command::END_GAME).unwrap(),
]);
// Can only count game ticks
let tick_parser = builder.build_clone();
let builder =
builder.command(ReplayCommandId::try_from(replay_command::VERIFY_CHECKSUM).unwrap());
// Can count game ticks and detect desyncs
let desync_parser = builder.build_clone();
let builder =
builder.command(ReplayCommandId::try_from(replay_command::LUA_SIM_CALLBACK).unwrap());
// Can count game ticks, detect desyncs, and extract chat messages
let message_parser = builder.build();Sourcepub fn build_stream_clone(&self) -> StreamParser<V>
pub fn build_stream_clone(&self) -> StreamParser<V>
Like build_clone but creates a new StreamParser.
Sourcepub fn command(self, command: V::CommandId) -> ParserBuilder<V>
pub fn command(self, command: V::CommandId) -> ParserBuilder<V>
Add a command to the ParserOptions.
Sourcepub fn commands(self, commands: &[V::CommandId]) -> ParserBuilder<V>
pub fn commands(self, commands: &[V::CommandId]) -> ParserBuilder<V>
Add multiple commands to the ParserOptions.
Sourcepub fn commands_all(self) -> ParserBuilder<V>
pub fn commands_all(self) -> ParserBuilder<V>
Add all supported commands to the ParserOptions.
Sourcepub fn commands_default(self) -> ParserBuilder<V>
pub fn commands_default(self) -> ParserBuilder<V>
Add the default set of commands to the ParserOptions.
Default commands are ADVANCE, SET_COMMAND_SOURCE, COMMAND_SOURCE_TERMINATED,
VERIFY_CHECKSUM, and END_GAME
Sourcepub fn limit(self, limit: Option<usize>) -> ParserBuilder<V>
pub fn limit(self, limit: Option<usize>) -> ParserBuilder<V>
Set a limit on the number of commands to parse. This only applies to commands in the
ParserOptions.commands field.
Sourcepub fn save_commands(self, save_commands: bool) -> ParserBuilder<V>
pub fn save_commands(self, save_commands: bool) -> ParserBuilder<V>
Whether or not to store the parsed commands in the parsed ReplayBody. When set to false,
Replay.body.commands.len() will always be 0.
Sourcepub fn stop_on_desync(self, stop_on_desync: bool) -> ParserBuilder<V>
pub fn stop_on_desync(self, stop_on_desync: bool) -> ParserBuilder<V>
Whether or not to return an error if a desync is detected. When set to false,
Replay.sim.desync_ticks will be a list of all desynced ticks.