mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-06-01 09:42:41 +00:00
feat(protocols): Add more control over gathering additional information (#180)
* protocols: Add more control over gathering additional information Adds GatherToggle which allows choosing the behaviour for how the query handles fetching additional information. The choices are: - DontGather - Don't attempt to fetch information - AttemptGather - Try to fetch the information but ignore errors - Required - Try to fetch information and fail if it errors A handy macro was also added to utils to dispatch additional queries based on a GatherToggle value. * Add/Update badge * protocols: Improve GatherToggle enum names Co-Authored-By: Cain <75994858+cainthebest@users.noreply.github.com> Co-Authored-By: CosminPerRam <cosmin.p@live.com> * Add/Update badge --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Cain <75994858+cainthebest@users.noreply.github.com> Co-authored-by: CosminPerRam <cosmin.p@live.com>
This commit is contained in:
parent
6d0c25d6ea
commit
89ed19f089
10 changed files with 195 additions and 64 deletions
|
|
@ -19,7 +19,7 @@ use crate::{
|
|||
},
|
||||
},
|
||||
socket::{Socket, UdpSocket},
|
||||
utils::{retry_on_timeout, u8_lower_upper},
|
||||
utils::{maybe_gather, retry_on_timeout, u8_lower_upper},
|
||||
GDErrorKind::{BadGame, Decompress, UnknownEnumCast},
|
||||
GDResult,
|
||||
};
|
||||
|
|
@ -470,13 +470,13 @@ fn get_response(
|
|||
|
||||
Ok(Response {
|
||||
info,
|
||||
players: match gather_settings.players {
|
||||
false => None,
|
||||
true => Some(client.get_server_players(&engine, protocol)?),
|
||||
},
|
||||
rules: match gather_settings.rules {
|
||||
false => None,
|
||||
true => Some(client.get_server_rules(&engine, protocol)?),
|
||||
},
|
||||
players: maybe_gather!(
|
||||
gather_settings.players,
|
||||
client.get_server_players(&engine, protocol)
|
||||
),
|
||||
rules: maybe_gather!(
|
||||
gather_settings.rules,
|
||||
client.get_server_rules(&engine, protocol)
|
||||
),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue