1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 18:24:05 +02:00

fmt+clippy

This commit is contained in:
Robin Appelman 2025-02-19 20:32:49 +01:00
commit 2bad24dedd
30 changed files with 947 additions and 3396 deletions

View file

@ -39,7 +39,7 @@ jobs:
with: with:
name: ci name: ci
instance: https://cache.icewind.me instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}' authToken: "${{ secrets.ATTIC_TOKEN }}"
- run: nix run .#demostf-parser-schema > schema.json - run: nix run .#demostf-parser-schema > schema.json
- run: | - run: |
git diff git diff

View file

@ -22,7 +22,7 @@ which will place the binary at `target/release/parse_demo`
Basic usage is as simple as `parse_demo demofile.dem` which will output a "summary" of the demo file in JSON format. Basic usage is as simple as `parse_demo demofile.dem` which will output a "summary" of the demo file in JSON format.
Passing the `detailed_summary` argument to the end of `parse_demo` will output a table with scoreboard information for all players who were ever on the server while the demo Passing the `detailed_summary` argument to the end of `parse_demo` will output a table with scoreboard information for all players who were ever on the server while the demo
was being recorded. The player who created the demo will be highlighted in the output. was being recorded. The player who created the demo will be highlighted in the output.
## Advanced usage ## Advanced usage

View file

@ -29,6 +29,6 @@
demostf-parser-schema = pkgs: pkgs.demostf-parser-schema; demostf-parser-schema = pkgs: pkgs.demostf-parser-schema;
}; };
tools = pkgs: with pkgs; [cargo-insta]; tools = pkgs: with pkgs; [bacon cargo-insta];
}; };
} }

File diff suppressed because it is too large Load diff

View file

@ -157,7 +157,7 @@ impl<'a> BitRead<'a, LittleEndian> for UserMessage<'a> {
} }
} }
impl<'a> BitWrite<LittleEndian> for UserMessage<'a> { impl BitWrite<LittleEndian> for UserMessage<'_> {
fn write(&self, stream: &mut BitWriteStream<LittleEndian>) -> ReadResult<()> { fn write(&self, stream: &mut BitWriteStream<LittleEndian>) -> ReadResult<()> {
self.message_type().write(stream)?; self.message_type().write(stream)?;
stream.reserve_length(11, |stream| match self { stream.reserve_length(11, |stream| match self {

View file

@ -104,7 +104,7 @@ impl<'a> BitRead<'a, LittleEndian> for ParseSoundsMessage<'a> {
} }
} }
impl<'a> BitWrite<LittleEndian> for ParseSoundsMessage<'a> { impl BitWrite<LittleEndian> for ParseSoundsMessage<'_> {
fn write(&self, stream: &mut BitWriteStream<LittleEndian>) -> ReadResult<()> { fn write(&self, stream: &mut BitWriteStream<LittleEndian>) -> ReadResult<()> {
self.reliable.write(stream)?; self.reliable.write(stream)?;
if !self.reliable { if !self.reliable {

View file

@ -73,13 +73,13 @@ pub struct DemoHandler<'a, T: MessageHandler> {
pub state_handler: ParserState, pub state_handler: ParserState,
} }
impl<'a> DemoHandler<'a, NullHandler> { impl DemoHandler<'_, NullHandler> {
pub fn new() -> Self { pub fn new() -> Self {
Self::parse_all_with_analyser(NullHandler) Self::parse_all_with_analyser(NullHandler)
} }
} }
impl<'a> Default for DemoHandler<'a, NullHandler> { impl Default for DemoHandler<'_, NullHandler> {
fn default() -> Self { fn default() -> Self {
DemoHandler::new() DemoHandler::new()
} }

View file

@ -63,24 +63,24 @@ pub struct DemoParser<'a, A: MessageHandler> {
} }
impl<'a> DemoParser<'a, Analyser> { impl<'a> DemoParser<'a, Analyser> {
pub fn new(stream: Stream<'a>) -> DemoParser<Analyser> { pub fn new(stream: Stream<'a>) -> Self {
DemoParser::new_with_analyser(stream, Analyser::new()) DemoParser::new_with_analyser(stream, Analyser::new())
} }
pub fn new_all(stream: Stream<'a>) -> DemoParser<Analyser> { pub fn new_all(stream: Stream<'a>) -> Self {
DemoParser::new_all_with_analyser(stream, Analyser::new()) DemoParser::new_all_with_analyser(stream, Analyser::new())
} }
} }
impl<'a, A: MessageHandler> DemoParser<'a, A> { impl<'a, A: MessageHandler> DemoParser<'a, A> {
pub fn new_with_analyser(stream: Stream<'a>, analyser: A) -> DemoParser<A> { pub fn new_with_analyser(stream: Stream<'a>, analyser: A) -> Self {
DemoParser { DemoParser {
handler: DemoHandler::with_analyser(analyser), handler: DemoHandler::with_analyser(analyser),
stream, stream,
} }
} }
pub fn new_all_with_analyser(stream: Stream<'a>, analyser: A) -> DemoParser<A> { pub fn new_all_with_analyser(stream: Stream<'a>, analyser: A) -> Self {
DemoParser { DemoParser {
handler: DemoHandler::parse_all_with_analyser(analyser), handler: DemoHandler::parse_all_with_analyser(analyser),
stream, stream,
@ -158,7 +158,7 @@ pub struct DemoTicker<'a, A: MessageHandler> {
packets: RawPacketStream<'a>, packets: RawPacketStream<'a>,
} }
impl<'a, A: MessageHandler> DemoTicker<'a, A> { impl<A: MessageHandler> DemoTicker<'_, A> {
/// Process the next packet /// Process the next packet
/// ///
/// returns whether or not there are still packets left in the demo /// returns whether or not there are still packets left in the demo
@ -179,7 +179,7 @@ impl<'a, A: MessageHandler> DemoTicker<'a, A> {
} }
} }
impl<'a, A: MessageHandler + BorrowMessageHandler> DemoTicker<'a, A> { impl<A: MessageHandler + BorrowMessageHandler> DemoTicker<'_, A> {
pub fn state(&self) -> &A::Output { pub fn state(&self) -> &A::Output {
self.handler.borrow_output() self.handler.borrow_output()
} }

View file

@ -71,7 +71,7 @@ impl StaticBaseline {
} }
} }
impl<'a> ParserState { impl ParserState {
pub fn new( pub fn new(
protocol_version: u32, protocol_version: u32,
analyser_handles: fn(message_type: MessageType) -> bool, analyser_handles: fn(message_type: MessageType) -> bool,
@ -294,12 +294,7 @@ impl<'a> ParserState {
} }
} }
pub fn handle_string_entry( pub fn handle_string_entry(&mut self, table: &str, _index: usize, entry: &StringTableEntry) {
&mut self,
table: &str,
_index: usize,
entry: &StringTableEntry<'a>,
) {
if table == "instancebaseline" { if table == "instancebaseline" {
if let (Some(extra), Ok(class_id)) = (&entry.extra_data, entry.text().parse()) { if let (Some(extra), Ok(class_id)) = (&entry.extra_data, entry.text().parse()) {
let baseline = StaticBaseline::new(class_id, extra.data.to_owned()); let baseline = StaticBaseline::new(class_id, extra.data.to_owned());

View file

@ -1,5 +1,5 @@
{ {
"max_entries": 8192, "max_entries": 8192,
"fixed_userdata_size": null, "fixed_userdata_size": null,
"count": 1 "count": 1
} }