mirror of
https://github.com/tribufu/rust-gamedig
synced 2026-05-06 07:17:27 +00:00
fix(clippy): add lifetime annotations to various methods and structs (mismatched_lifetime_syntaxes)
This commit is contained in:
parent
a5f15a040a
commit
4ea333f16b
17 changed files with 33 additions and 33 deletions
|
|
@ -244,7 +244,7 @@ pub struct GameNameParsed<'a> {
|
|||
year: Option<u16>,
|
||||
}
|
||||
|
||||
pub fn extract_game_parts_from_name(game: &str) -> GameNameParsed {
|
||||
pub fn extract_game_parts_from_name(game: &str) -> GameNameParsed<'_> {
|
||||
// Separate game name into words
|
||||
// NOTE: we have to leave "-" in to prevent hyphenated prefixes being parsed as
|
||||
// numerals
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> crate::protocols::types::GenericPlayer {
|
||||
fn as_original(&self) -> crate::protocols::types::GenericPlayer<'_> {
|
||||
crate::protocols::types::GenericPlayer::Eco(self)
|
||||
}
|
||||
|
||||
|
|
@ -201,7 +201,7 @@ impl From<Root> for Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> crate::protocols::GenericResponse { crate::protocols::GenericResponse::Eco(self) }
|
||||
fn as_original(&self) -> crate::protocols::GenericResponse<'_> { crate::protocols::GenericResponse::Eco(self) }
|
||||
|
||||
fn players_online(&self) -> u32 { self.players_online }
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::FFOW(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::FFOW(self) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn game_mode(&self) -> Option<&str> { Some(&self.game_mode) }
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::JCMP2(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::JCMP2(self) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
}
|
||||
|
|
@ -30,7 +30,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::JC2M(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::JC2M(self) }
|
||||
|
||||
fn game_version(&self) -> Option<&str> { Some(&self.game_version) }
|
||||
fn description(&self) -> Option<&str> { Some(&self.description) }
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ impl GameMode {
|
|||
}
|
||||
|
||||
impl CommonResponse for ServerData {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Mindustry(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Mindustry(self) }
|
||||
|
||||
fn players_online(&self) -> u32 { self.players.try_into().unwrap_or(0) }
|
||||
fn players_maximum(&self) -> u32 { self.player_limit.try_into().unwrap_or(0) }
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::Minecraft(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::Minecraft(self) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
}
|
||||
|
|
@ -134,7 +134,7 @@ impl From<ExtraRequestSettings> for RequestSettings {
|
|||
}
|
||||
|
||||
impl CommonResponse for JavaResponse {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Minecraft(VersionedResponse::Java(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Minecraft(VersionedResponse::Java(self)) }
|
||||
|
||||
fn description(&self) -> Option<&str> { Some(&self.description) }
|
||||
fn players_maximum(&self) -> u32 { self.players_maximum }
|
||||
|
|
@ -175,7 +175,7 @@ pub struct BedrockResponse {
|
|||
}
|
||||
|
||||
impl CommonResponse for BedrockResponse {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Minecraft(VersionedResponse::Bedrock(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Minecraft(VersionedResponse::Bedrock(self)) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn map(&self) -> Option<&str> { self.map.as_deref() }
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Savage2(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Savage2(self) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn game_mode(&self) -> Option<&str> { Some(&self.game_mode) }
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl TheShipPlayer {
|
|||
}
|
||||
|
||||
impl CommonPlayer for TheShipPlayer {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::TheShip(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::TheShip(self) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
fn score(&self) -> Option<i32> { Some(self.score) }
|
||||
|
|
@ -64,7 +64,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::TheShip(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::TheShip(self) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn map(&self) -> Option<&str> { Some(&self.map) }
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::Gamespy(VersionedPlayer::One(self)) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::Gamespy(VersionedPlayer::One(self)) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
fn score(&self) -> Option<i32> { Some(self.score) }
|
||||
|
|
@ -52,7 +52,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::GameSpy(VersionedResponse::One(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::GameSpy(VersionedResponse::One(self)) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn map(&self) -> Option<&str> { Some(&self.map) }
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> crate::protocols::types::GenericPlayer {
|
||||
fn as_original(&self) -> crate::protocols::types::GenericPlayer<'_> {
|
||||
GenericPlayer::Gamespy(VersionedPlayer::Three(self))
|
||||
}
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::GameSpy(VersionedResponse::Three(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::GameSpy(VersionedResponse::Three(self)) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn map(&self) -> Option<&str> { Some(&self.map) }
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::Gamespy(VersionedPlayer::Two(self)) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::Gamespy(VersionedPlayer::Two(self)) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
fn score(&self) -> Option<i32> { Some(self.score.into()) }
|
||||
|
|
@ -45,7 +45,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::GameSpy(VersionedResponse::Two(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::GameSpy(VersionedResponse::Two(self)) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn map(&self) -> Option<&str> { Some(&self.map) }
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl QuakePlayerType for Player {
|
||||
fn version(response: &Response<Self>) -> super::VersionedResponse { super::VersionedResponse::One(response) }
|
||||
fn version(response: &Response<Self>) -> super::VersionedResponse<'_> { super::VersionedResponse::One(response) }
|
||||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::QuakeOne(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::QuakeOne(self) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
fn score(&self) -> Option<i32> { Some(self.score.into()) }
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ pub struct Player {
|
|||
}
|
||||
|
||||
impl QuakePlayerType for Player {
|
||||
fn version(response: &Response<Self>) -> super::VersionedResponse {
|
||||
fn version(response: &Response<Self>) -> super::VersionedResponse<'_> {
|
||||
super::VersionedResponse::TwoAndThree(response)
|
||||
}
|
||||
}
|
||||
|
||||
impl CommonPlayer for Player {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::QuakeTwo(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::QuakeTwo(self) }
|
||||
|
||||
fn name(&self) -> &str { &self.name }
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,11 @@ pub struct Response<P> {
|
|||
}
|
||||
|
||||
pub trait QuakePlayerType: Sized + CommonPlayer {
|
||||
fn version(response: &Response<Self>) -> VersionedResponse;
|
||||
fn version(response: &Response<Self>) -> VersionedResponse<'_>;
|
||||
}
|
||||
|
||||
impl<P: QuakePlayerType> CommonResponse for Response<P> {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Quake(P::version(self)) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Quake(P::version(self)) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.name) }
|
||||
fn game_version(&self) -> Option<&str> { self.game_version.as_deref() }
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ pub enum GenericPlayer<'a> {
|
|||
|
||||
pub trait CommonResponse {
|
||||
/// Get the original response type
|
||||
fn as_original(&self) -> GenericResponse;
|
||||
fn as_original(&self) -> GenericResponse<'_>;
|
||||
/// Get a struct that can be stored as JSON (you don't need to override
|
||||
/// this)
|
||||
fn as_json(&self) -> CommonResponseJson {
|
||||
fn as_json(&self) -> CommonResponseJson<'_> {
|
||||
CommonResponseJson {
|
||||
name: self.name(),
|
||||
description: self.description(),
|
||||
|
|
@ -163,10 +163,10 @@ pub struct CommonResponseJson<'a> {
|
|||
|
||||
pub trait CommonPlayer {
|
||||
/// Get the original player type
|
||||
fn as_original(&self) -> GenericPlayer;
|
||||
fn as_original(&self) -> GenericPlayer<'_>;
|
||||
/// Get a struct that can be stored as JSON (you don't need to override
|
||||
/// this)
|
||||
fn as_json(&self) -> CommonPlayerJson {
|
||||
fn as_json(&self) -> CommonPlayerJson<'_> {
|
||||
CommonPlayerJson {
|
||||
name: self.name(),
|
||||
score: self.score(),
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ impl CommonPlayer for Player {
|
|||
|
||||
fn score(&self) -> Option<i32> { Some(self.score) }
|
||||
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::Unreal2(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::Unreal2(self) }
|
||||
}
|
||||
|
||||
/// Unreal 2 response.
|
||||
|
|
@ -180,7 +180,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Unreal2(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Unreal2(self) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.server_info.name) }
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl CommonResponse for Response {
|
||||
fn as_original(&self) -> GenericResponse { GenericResponse::Valve(self) }
|
||||
fn as_original(&self) -> GenericResponse<'_> { GenericResponse::Valve(self) }
|
||||
|
||||
fn name(&self) -> Option<&str> { Some(&self.info.name) }
|
||||
fn game_mode(&self) -> Option<&str> { Some(&self.info.game_mode) }
|
||||
|
|
@ -135,7 +135,7 @@ pub struct ServerPlayer {
|
|||
}
|
||||
|
||||
impl CommonPlayer for ServerPlayer {
|
||||
fn as_original(&self) -> GenericPlayer { GenericPlayer::Valve(self) }
|
||||
fn as_original(&self) -> GenericPlayer<'_> { GenericPlayer::Valve(self) }
|
||||
fn name(&self) -> &str { &self.name }
|
||||
fn score(&self) -> Option<i32> { Some(self.score) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue