Make public functions that are meant to be used internally private.

This commit is contained in:
CosminPerRam 2022-12-29 16:59:51 +02:00
parent 8c98433da9
commit 0e68f8c830
4 changed files with 11 additions and 13 deletions

View file

@ -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).

View file

@ -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(),

View file

@ -123,7 +123,7 @@ impl GameMode {
}
}
pub fn get_varint(buffer: &mut Bufferer) -> GDResult<i32> {
pub(crate) fn get_varint(buffer: &mut Bufferer) -> GDResult<i32> {
let mut result = 0;
let msb: u8 = 0b10000000;
@ -147,7 +147,7 @@ pub fn get_varint(buffer: &mut Bufferer) -> GDResult<i32> {
Ok(result)
}
pub fn as_varint(value: i32) -> Vec<u8> {
pub(crate) fn as_varint(value: i32) -> Vec<u8> {
let mut bytes = vec![];
let mut reading_value = value;
@ -171,7 +171,7 @@ pub fn as_varint(value: i32) -> Vec<u8> {
bytes
}
pub fn get_string(buffer: &mut Bufferer) -> GDResult<String> {
pub(crate) fn get_string(buffer: &mut Bufferer) -> GDResult<String> {
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<String> {
.map_err(|_| GDError::PacketBad("Couldn't parse to a Minecraft String.".to_string()))?)
}
pub fn as_string(value: String) -> Vec<u8> {
#[allow(dead_code)]
pub(crate) fn as_string(value: String) -> Vec<u8> {
let mut buf = as_varint(value.len() as i32);
buf.extend(value.as_bytes().to_vec());

View file

@ -122,7 +122,7 @@ pub struct ModData {
pub has_own_dll: bool
}
pub fn get_optional_extracted_data(data: Option<ExtraData>) -> (Option<u16>, Option<u64>, Option<u16>, Option<String>, Option<String>) {
pub(crate) fn get_optional_extracted_data(data: Option<ExtraData>) -> (Option<u16>, Option<u64>, Option<u16>, Option<String>, Option<String>) {
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<ExtraData>) -> (Option<u16>, 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};