* [Generic] Add struct for all extra request settings
Adds a new struct `ExtraRequestSettings` that contains all possible
extra settings for all protocols, and can be implicitly converted with
`.into()` into each protocol's extra settings type.
This is then used in a new query method
`query_with_timeout_and_extra_settings()` that passes the object on to
the selected protocol.
This also updates the generic example to set some of these generic
settings so that it can be used for certain queries like
"mc.hypixel.net".
* [Minecraft] Add `request_settings` parameter to auto query
This allows generic queries to pass through request settings when using
the `mc` game so that servers like `mc.hypixel.net` will still work when
using auto query.
* Fix generic examples tests (and enable example tests in pre-commit)
* Make initial fix
* Fix imports
* Rename query_address to hostname and add this to the mc example
* Fix master_querant example not compiling
* Add extra safety on converting strings to Minecraft Varint strings
* Add docs to RequestSettings
* Fix formatting
* [Protocol] Standardize The Ship fields
* [Protocol] Standardize FFOW fields
* [Protocol] Rename Valve's protocol field to protocol_version
* [Protocol] Rename Minecraft's version_protocol field to protocol_version
* [Protocol] Rename Valve's version field to game_version
* [Protocol] Rename Minecraft java version_name to game_version
* [Crate] Reformat RESPONSES.md
* [Protocol] Renamed Minecraft Java players_sample to players
* [Protocol] Rename Quake (1,2,3) version field to game_version
* [Protocol] Rename quake (1 and 2) game_type field to game_mode
* [Protocol] Rename Valve, FFOW, TS game field to game_mode
* [Generics] Rename game field/function to game_mode
* [Protocol] Change players_minimum, _maximum and _bots from those who werent u8 or u32 to u32
* [Protocol] Change instances of player score field type from u32 to i32
* [Crate] Nicer gramar in CHANGELOG
* [Protocol] Apply clippy fixes
* Add rich error type with source and backtrace
Adds a rich error type that will take a backtrace and allow capturing
the source of the error. The best way to use this is with the included
helpers that will automatically capture the backtrace and convert the
source error:
```
GDRichError::packet_bad_from_into("Reason packet was bad")
```
* [Crate] Bump MSRV to 1.65.0
This is required for backtraces in rich errors.
* Remove leftover debug logging
* [Errors] Replace variant overloads with single .rich method on kind enum
This overhaul replaces the exhaustive impls of each variant as multiple
methods on the rich error type with a singular .rich() method on the
kind enum. This consumes the variant and converts it to a rich error
with a source (.into() can be used if a source is not needed).
I also took the liberty of replacing all usages with the this new method
as I saw fit (adding various error messages) and converting a few
PacketBad errors to TypeParse errors when they are the result of parse
failing.
* Fix problem with rustdoc
* Remove BadGame's owned string
* Rename GDError to GDErrorKind
* Rename GDRichError to GDError
* Remove error impl from GDErrorKind
* Fix tests not passing
* Use error context everywhere map_err is used
* Improve GDError display formatter
* Add tests for new error type
* [Protocol] Add CUSTOM to protocol enumeration
* [Protocol] Rename CUSTOM to PROPRIETARY
* [Protocol] Rename struct to ProprietaryProtocol and do the same thing to generic response
* [Protocol] Revert proprietary change on generic response
* Implement generic response as enum
* First draft of implementing into_common()
* Make common response type generic
* Use macros and generics to reduce repetition
* [Games] Add dynamically dispatched CommonResponse trait
This adds two traits: "CommonResponse", and "CommonPlayer", when the
generic game query function returns a response it returns a pointer to
its original response type that implements "CommonResponse".
Both common traits require that "as_original()" be implemented, this
returns an enum containing a pointer to the original type.
Both traits have a concrete method "as_json()" that returns a struct
containing data fetched from all of its methods as. This struct
implements serde and can hence be serialized as required.
The traits require a few other methods be implemented, those being the
fields that are common across all types. All other methods have a
default None implementation so that each response type only needs to
implement methods for fields that it has.
* [Game] Implement common traits for JCMP2 response
* [Fmt] Run cargo fmt
* Fix doctest failing
* Run cargo fmt
* [Game] Add JC2MP support.
* [Game] Add game to changelog and games
* [Games] Add generic support to JC2MP.
* [Game] Add players_maximum and players_online
* Define games as structs
* Create table of response types
* Ensure serde is always included
* Remove server_ prefix in GenericResponse
* Make players online/max non-optional in generic response
* Use already existing minecraft server enum
* Implement ExtraResponses to prevent cloning when creating generic
* Add game definitions
* Add doc comments to generic types
* Include players in gamespy extra responses
* Add custom response types for TheShip and FFOW
* Cargo format differing files
* Final cleanup
* [Protocol] Add initial files
* [Protocol] Add test to test the request
* [Protocol] Add initial query response type
* [Protocol] Parse teams
* [Protocol] Add players parse and add nice macro
* [Protocol] Add proper derives to structs
* [Protocol] Change to get all informations from one request
* [Protocol] Add Halo: CE support and update CHANGELOG.md
* [Protocol] Remove a .clone usage
* [Protocol] Add todo comment regarding code performance
* [Protocol] Use iterator instead of index range
* [Protocol] Initial packet receive implementation
* [Protocol] Add key extraction
* [Protocol] Fix new Ipv4Addr query address and get string with unended
* [Protocol] Properly parse the received data
* [Protocol] Add parse players
* [Protocol] Add bots
* [Protocol] Extract into functions
* [Protocol] Remove quotes from player name
* [Protocol] Add two and three files
* [Protocol] Make quake queries very modular
* [Protocol] Remove the need of a client instance
* [Protocol] Revesed if statement
* [Protocol] Apply clippy fixes and replace String by &str in get send header
* [Protocol] Add one and three implementations
* [Protocol] Add quake2 and quake3 to master_querant
* [Protocol] Fix Q2 implementation
* [Protocol] Change from Ipv4Addr to IpAddr
* [Protocol] Fix Q3 response header
* [Protocol] Fix Q3 response
* [Crate] Add Q1, 2 and 3 to changelog and protocols
* [Protocol] Extract client into separate file and add some docs
Replace usages of Ipv4Addr with IpAddr which allows the use of either Ipv4 or Ipv6.
This patch essentially consists of running:
"sed -i 's/Ipv4Addr/IpAddr/g' src/**/*.rs examples/*"
and fixing the errors.
* [Protocol] Gamespy3 initial code
* [Protocol] Add rest of challenge solving
* [Protocol] Remove unused stuff
* [Protocol] Remove adding unused bytes
* [Protocol] Clean up code
* [Protocol] Make gs3 a struct
* [Protocol] Add initial key-value parsing
* [Protocol] Manage multiple packets
* [Protocol] Split server vars and other vars
* Revert "[Protocol] Split server vars and other vars"
This reverts commit 9a930aeb68802fcf3d0908a2e031dfea054d37d0.
* [Protocol] Proper packet management and initial response struct
* [Protocol] Fix players_minimum
* [Protocol] Fix server vars to parse only the first packet
* [Protocol] Update CHANGELOG.md
* [Protocol] Initial player parsing
* [Protocol] Split GS one and three
* [Protocol] Add common code file
* [Protocol] Change static to const
* [Protocol] Fix players_online and break on data to map on empty key
* [Protocol] Remove unused types and printlns
* [Protocol] Add teams parsing
* [Protocol] Split key_values and parsing data
* [Crate] Update PROTOCOLS.md
* chore: add standard for formatting
* chore: manually tidy up imports and format
* chore: remove vscode and add to gitignore
* chore: alphabetically order and fix
* chore: format
* chore: fix format issue with payload
* chore: format as merge had unformatted code
* [format] Fix comments, change max width and binop operator
---------
Co-authored-by: CosminPerRam <cosmin.p@live.com>