From 0e68f8c83065732cae47bd4478c98b8ec079d357 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Thu, 29 Dec 2022 16:59:51 +0200 Subject: [PATCH] Make public functions that are meant to be used internally private. --- CHANGELOG.md | 3 ++- src/bufferer.rs | 4 ---- src/protocols/minecraft/types.rs | 9 +++++---- src/protocols/valve/types.rs | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5df8a6..4eaac5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,8 @@ Fix Minecraft legacy v1.6 max/online players count being reversed. Added `query_legacy_specific` method to the Minecraft protocol. ### Breaking: -Removed `query_specific` from the mc protocol in favor of `query_java`, `query_legacy` and `query_legacy_specific`. +Removed `query_specific` from the mc protocol in favor of `query_java`, `query_legacy` and `query_legacy_specific`. +Some public functions that are meant to be used only internally were made private. # 0.0.6 - 28/11/2022 [Minecraft](https://www.minecraft.com) support (bedrock not supported yet). diff --git a/src/bufferer.rs b/src/bufferer.rs index 20feb0d..5db3f60 100644 --- a/src/bufferer.rs +++ b/src/bufferer.rs @@ -11,10 +11,6 @@ pub struct Bufferer { } impl Bufferer { - pub fn new(endianess: Endianess) -> Self { - Bufferer::new_with_data(endianess, &[]) - } - pub fn new_with_data(endianess: Endianess, data: &[u8]) -> Self { Bufferer { data: data.to_vec(), diff --git a/src/protocols/minecraft/types.rs b/src/protocols/minecraft/types.rs index 74976c3..58116b2 100644 --- a/src/protocols/minecraft/types.rs +++ b/src/protocols/minecraft/types.rs @@ -123,7 +123,7 @@ impl GameMode { } } -pub fn get_varint(buffer: &mut Bufferer) -> GDResult { +pub(crate) fn get_varint(buffer: &mut Bufferer) -> GDResult { let mut result = 0; let msb: u8 = 0b10000000; @@ -147,7 +147,7 @@ pub fn get_varint(buffer: &mut Bufferer) -> GDResult { Ok(result) } -pub fn as_varint(value: i32) -> Vec { +pub(crate) fn as_varint(value: i32) -> Vec { let mut bytes = vec![]; let mut reading_value = value; @@ -171,7 +171,7 @@ pub fn as_varint(value: i32) -> Vec { bytes } -pub fn get_string(buffer: &mut Bufferer) -> GDResult { +pub(crate) fn get_string(buffer: &mut Bufferer) -> GDResult { let length = get_varint(buffer)? as usize; let mut text = vec![0; length]; @@ -183,7 +183,8 @@ pub fn get_string(buffer: &mut Bufferer) -> GDResult { .map_err(|_| GDError::PacketBad("Couldn't parse to a Minecraft String.".to_string()))?) } -pub fn as_string(value: String) -> Vec { +#[allow(dead_code)] +pub(crate) fn as_string(value: String) -> Vec { let mut buf = as_varint(value.len() as i32); buf.extend(value.as_bytes().to_vec()); diff --git a/src/protocols/valve/types.rs b/src/protocols/valve/types.rs index c4e5bbc..f126ad0 100644 --- a/src/protocols/valve/types.rs +++ b/src/protocols/valve/types.rs @@ -122,7 +122,7 @@ pub struct ModData { pub has_own_dll: bool } -pub fn get_optional_extracted_data(data: Option) -> (Option, Option, Option, Option, Option) { +pub(crate) fn get_optional_extracted_data(data: Option) -> (Option, Option, Option, Option, Option) { match data { None => (None, None, None, None, None), Some(ed) => (ed.port, ed.steam_id, ed.tv_port, ed.tv_name, ed.keywords) @@ -132,7 +132,7 @@ pub fn get_optional_extracted_data(data: Option) -> (Option, Opt /// The type of the request, see the [protocol](https://developer.valvesoftware.com/wiki/Server_queries). #[derive(PartialEq, Clone)] #[repr(u8)] -pub enum Request { +pub(crate) enum Request { /// Known as `A2S_INFO` INFO = 0x54, /// Known as `A2S_PLAYERS` @@ -211,7 +211,7 @@ impl SteamID { } } -/// App type +/// App type. #[derive(PartialEq, Clone)] pub enum App { /// A Source game, the argument represents the wanted response steam app id, if its **None**, @@ -240,7 +240,7 @@ impl Default for GatheringSettings { } /// Generic response types that are used by many games, they are the protocol ones, but without the -/// unnecessary bits (example: the **The Ship**-only fields) +/// unnecessary bits (example: the **The Ship**-only fields). pub mod game { use crate::protocols::valve::types::get_optional_extracted_data; use super::{Server, ServerRule, ServerPlayer};