aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-06-25 02:33:28 -0500
committermat <github@matdoes.dev>2022-06-25 02:33:28 -0500
commitcd9a05e5a62190b3d4a2a733bf637d6324aec5fd (patch)
tree15fb360678dfb5e8d81330144b810735b73f6ef4 /azalea-protocol
parentc9faf25fab4f89319731fec87ad4d2cf45864632 (diff)
downloadazalea-drasl-cd9a05e5a62190b3d4a2a733bf637d6324aec5fd.tar.xz
read_into -> read_from
yeah
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/packet-macros/src/lib.rs2
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs32
-rw-r--r--azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs22
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs2
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_info_packet.rs12
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_position_packet.rs2
-rw-r--r--azalea-protocol/src/packets/game/clientbound_recipe_packet.rs2
-rw-r--r--azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs6
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs2
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs28
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_tags_packet.rs10
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_game_profile_packet.rs2
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs8
-rwxr-xr-xazalea-protocol/src/packets/mod.rs2
16 files changed, 70 insertions, 70 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs
index 58487cdd..2e40cbd1 100755
--- a/azalea-protocol/packet-macros/src/lib.rs
+++ b/azalea-protocol/packet-macros/src/lib.rs
@@ -32,7 +32,7 @@ fn as_packet_derive(input: TokenStream, state: proc_macro2::TokenStream) -> Toke
buf: &mut impl std::io::Read,
) -> Result<#state, String> {
use azalea_buf::McBufReadable;
- Ok(Self::read_into(buf)?.get())
+ Ok(Self::read_from(buf)?.get())
}
}
};
diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
index bf29a050..ee3f21a2 100755
--- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
@@ -25,15 +25,15 @@ pub struct BrigadierNumber<T> {
max: Option<T>,
}
impl<T: McBufReadable> McBufReadable for BrigadierNumber<T> {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let flags = buf.read_byte()?;
let min = if flags & 0x01 != 0 {
- Some(T::read_into(buf)?)
+ Some(T::read_from(buf)?)
} else {
None
};
let max = if flags & 0x02 != 0 {
- Some(T::read_into(buf)?)
+ Some(T::read_from(buf)?)
} else {
None
};
@@ -124,16 +124,16 @@ pub enum BrigadierParser {
}
impl McBufReadable for BrigadierParser {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let parser_type = u32::var_read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let parser_type = u32::var_read_from(buf)?;
match parser_type {
0 => Ok(BrigadierParser::Bool),
- 1 => Ok(BrigadierParser::Float(BrigadierNumber::read_into(buf)?)),
- 2 => Ok(BrigadierParser::Double(BrigadierNumber::read_into(buf)?)),
- 3 => Ok(BrigadierParser::Integer(BrigadierNumber::read_into(buf)?)),
- 4 => Ok(BrigadierParser::Long(BrigadierNumber::read_into(buf)?)),
- 5 => Ok(BrigadierParser::String(BrigadierString::read_into(buf)?)),
+ 1 => Ok(BrigadierParser::Float(BrigadierNumber::read_from(buf)?)),
+ 2 => Ok(BrigadierParser::Double(BrigadierNumber::read_from(buf)?)),
+ 3 => Ok(BrigadierParser::Integer(BrigadierNumber::read_from(buf)?)),
+ 4 => Ok(BrigadierParser::Long(BrigadierNumber::read_from(buf)?)),
+ 5 => Ok(BrigadierParser::String(BrigadierString::read_from(buf)?)),
6 => {
let flags = buf.read_byte()?;
Ok(BrigadierParser::Entity {
@@ -183,10 +183,10 @@ impl McBufReadable for BrigadierParser {
41 => Ok(BrigadierParser::Dimension),
42 => Ok(BrigadierParser::Time),
43 => Ok(BrigadierParser::ResourceOrTag {
- registry_key: ResourceLocation::read_into(buf)?,
+ registry_key: ResourceLocation::read_from(buf)?,
}),
44 => Ok(BrigadierParser::Resource {
- registry_key: ResourceLocation::read_into(buf)?,
+ registry_key: ResourceLocation::read_from(buf)?,
}),
45 => Ok(BrigadierParser::TemplateMirror),
46 => Ok(BrigadierParser::TemplateRotation),
@@ -198,8 +198,8 @@ impl McBufReadable for BrigadierParser {
// TODO: BrigadierNodeStub should have more stuff
impl McBufReadable for BrigadierNodeStub {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let flags = u8::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let flags = u8::read_from(buf)?;
if flags > 31 {
println!(
"Warning: The flags from a Brigadier node are over 31 ({flags}; {flags:#b}). This is probably a bug.",
@@ -217,9 +217,9 @@ impl McBufReadable for BrigadierNodeStub {
// argument node
if node_type == 2 {
let _name = buf.read_utf()?;
- let _parser = BrigadierParser::read_into(buf)?;
+ let _parser = BrigadierParser::read_from(buf)?;
let _suggestions_type = if has_suggestions_type {
- Some(ResourceLocation::read_into(buf)?)
+ Some(ResourceLocation::read_from(buf)?)
} else {
None
};
diff --git a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
index df1174b7..a9ce57ad 100644
--- a/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_level_particles_packet.rs
@@ -20,17 +20,17 @@ pub struct ClientboundLevelParticlesPacket {
}
impl McBufReadable for ClientboundLevelParticlesPacket {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let particle_id = u32::var_read_into(buf)?;
- let override_limiter = bool::read_into(buf)?;
- let x = f64::read_into(buf)?;
- let y = f64::read_into(buf)?;
- let z = f64::read_into(buf)?;
- let x_dist = f32::read_into(buf)?;
- let y_dist = f32::read_into(buf)?;
- let z_dist = f32::read_into(buf)?;
- let max_speed = f32::read_into(buf)?;
- let count = u32::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let particle_id = u32::var_read_from(buf)?;
+ let override_limiter = bool::read_from(buf)?;
+ let x = f64::read_from(buf)?;
+ let y = f64::read_from(buf)?;
+ let z = f64::read_from(buf)?;
+ let x_dist = f32::read_from(buf)?;
+ let y_dist = f32::read_from(buf)?;
+ let z_dist = f32::read_from(buf)?;
+ let max_speed = f32::read_from(buf)?;
+ let count = u32::read_from(buf)?;
let data = ParticleData::read_from_particle_id(buf, particle_id)?;
diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
index d351ab04..bc3c653e 100755
--- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
@@ -20,7 +20,7 @@ pub struct PlayerAbilitiesFlags {
}
impl McBufReadable for PlayerAbilitiesFlags {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let byte = buf.read_byte()?;
Ok(PlayerAbilitiesFlags {
invulnerable: byte & 1 != 0,
diff --git a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
index f216fde8..522a371a 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_info_packet.rs
@@ -63,14 +63,14 @@ pub struct RemovePlayer {
}
impl McBufReadable for Action {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let id = buf.read_byte()?;
Ok(match id {
- 0 => Action::AddPlayer(Vec::<AddPlayer>::read_into(buf)?),
- 1 => Action::UpdateGameMode(Vec::<UpdateGameMode>::read_into(buf)?),
- 2 => Action::UpdateLatency(Vec::<UpdateLatency>::read_into(buf)?),
- 3 => Action::UpdateDisplayName(Vec::<UpdateDisplayName>::read_into(buf)?),
- 4 => Action::RemovePlayer(Vec::<RemovePlayer>::read_into(buf)?),
+ 0 => Action::AddPlayer(Vec::<AddPlayer>::read_from(buf)?),
+ 1 => Action::UpdateGameMode(Vec::<UpdateGameMode>::read_from(buf)?),
+ 2 => Action::UpdateLatency(Vec::<UpdateLatency>::read_from(buf)?),
+ 3 => Action::UpdateDisplayName(Vec::<UpdateDisplayName>::read_from(buf)?),
+ 4 => Action::RemovePlayer(Vec::<RemovePlayer>::read_from(buf)?),
_ => panic!("Unknown player info action id: {}", id),
})
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
index 29f7c1a3..d28d6620 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
@@ -28,7 +28,7 @@ pub struct RelativeArguments {
}
impl McBufReadable for RelativeArguments {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let byte = buf.read_byte()?;
Ok(RelativeArguments {
x: byte & 0b1 != 0,
diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
index a79bfcf1..a00774da 100644
--- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
@@ -41,7 +41,7 @@ impl McBufWritable for State {
}
}
impl McBufReadable for State {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let state = buf.read_varint()?;
Ok(match state {
0 => State::Init,
diff --git a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
index 6ee27ed1..60ebe26c 100644
--- a/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_section_blocks_update_packet.rs
@@ -18,8 +18,8 @@ pub struct BlockStateWithPosition {
}
impl McBufReadable for BlockStateWithPosition {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let data = u64::var_read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let data = u64::var_read_from(buf)?;
let position_part = data & 4095;
let state = (data >> 12) as u32;
let position = ChunkSectionBlockPos {
diff --git a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
index aa352189..769d24bb 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_equipment_packet.rs
@@ -17,14 +17,14 @@ pub struct EquipmentSlots {
}
impl McBufReadable for EquipmentSlots {
- fn read_into(buf: &mut impl std::io::Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl std::io::Read) -> Result<Self, String> {
let mut slots = vec![];
loop {
- let equipment_byte = u8::read_into(buf)?;
+ let equipment_byte = u8::read_from(buf)?;
let equipment_slot = EquipmentSlot::from_byte(equipment_byte & 127)
.ok_or_else(|| format!("Invalid equipment slot byte {}", equipment_byte))?;
- let item = Slot::read_into(buf)?;
+ let item = Slot::read_from(buf)?;
slots.push((equipment_slot, item));
if equipment_byte & 128 == 0 {
break;
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
index 43e4d69f..118dd477 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
@@ -45,8 +45,8 @@ pub struct DisplayFlags {
}
impl McBufReadable for DisplayFlags {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let data = u32::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let data = u32::read_from(buf)?;
Ok(DisplayFlags {
background: (data & 0b1) != 0,
show_toast: (data & 0b10) != 0,
diff --git a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
index 3eca2a84..c1f57cda 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_attributes_packet.rs
@@ -34,7 +34,7 @@ enum Operation {
}
impl McBufReadable for Operation {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
match buf.read_byte()? {
0 => Ok(Operation::Addition),
1 => Ok(Operation::MultiplyBase),
diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
index 05d57695..dc434eb7 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
@@ -49,15 +49,15 @@ impl McBufWritable for ShapedRecipe {
}
}
impl McBufReadable for ShapedRecipe {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let width = buf.read_varint()?.try_into().unwrap();
let height = buf.read_varint()?.try_into().unwrap();
let group = buf.read_utf()?;
let mut ingredients = Vec::with_capacity(width * height);
for _ in 0..width * height {
- ingredients.push(Ingredient::read_into(buf)?);
+ ingredients.push(Ingredient::read_from(buf)?);
}
- let result = Slot::read_into(buf)?;
+ let result = Slot::read_from(buf)?;
Ok(ShapedRecipe {
width,
@@ -129,17 +129,17 @@ impl McBufWritable for Recipe {
}
impl McBufReadable for Recipe {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let recipe_type = ResourceLocation::read_into(buf)?;
- let identifier = ResourceLocation::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let recipe_type = ResourceLocation::read_from(buf)?;
+ let identifier = ResourceLocation::read_from(buf)?;
// rust doesn't let us match ResourceLocation so we have to do a big
// if-else chain :(
let data = if recipe_type == ResourceLocation::new("minecraft:crafting_shapeless").unwrap()
{
- RecipeData::CraftingShapeless(ShapelessRecipe::read_into(buf)?)
+ RecipeData::CraftingShapeless(ShapelessRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:crafting_shaped").unwrap() {
- RecipeData::CraftingShaped(ShapedRecipe::read_into(buf)?)
+ RecipeData::CraftingShaped(ShapedRecipe::read_from(buf)?)
} else if recipe_type
== ResourceLocation::new("minecraft:crafting_special_armordye").unwrap()
{
@@ -197,17 +197,17 @@ impl McBufReadable for Recipe {
{
RecipeData::CraftingSpecialSuspiciousStew
} else if recipe_type == ResourceLocation::new("minecraft:smelting").unwrap() {
- RecipeData::Smelting(CookingRecipe::read_into(buf)?)
+ RecipeData::Smelting(CookingRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:blasting").unwrap() {
- RecipeData::Blasting(CookingRecipe::read_into(buf)?)
+ RecipeData::Blasting(CookingRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:smoking").unwrap() {
- RecipeData::Smoking(CookingRecipe::read_into(buf)?)
+ RecipeData::Smoking(CookingRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:campfire_cooking").unwrap() {
- RecipeData::CampfireCooking(CookingRecipe::read_into(buf)?)
+ RecipeData::CampfireCooking(CookingRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:stonecutting").unwrap() {
- RecipeData::Stonecutting(StoneCuttingRecipe::read_into(buf)?)
+ RecipeData::Stonecutting(StoneCuttingRecipe::read_from(buf)?)
} else if recipe_type == ResourceLocation::new("minecraft:smithing").unwrap() {
- RecipeData::Smithing(SmithingRecipe::read_into(buf)?)
+ RecipeData::Smithing(SmithingRecipe::read_from(buf)?)
} else {
panic!("Unknown recipe type sent by server: {}", recipe_type);
};
diff --git a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
index cf3bc069..caa97d7b 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_tags_packet.rs
@@ -23,15 +23,15 @@ pub struct Tags {
pub struct TagMap(HashMap<ResourceLocation, Vec<Tags>>);
impl McBufReadable for TagMap {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
let length = buf.read_varint()? as usize;
let mut data = HashMap::with_capacity(length);
for _ in 0..length {
- let tag_type = ResourceLocation::read_into(buf)?;
+ let tag_type = ResourceLocation::read_from(buf)?;
let tags_count = buf.read_varint()? as usize;
let mut tags_vec = Vec::with_capacity(tags_count);
for _ in 0..tags_count {
- let tags = Tags::read_into(buf)?;
+ let tags = Tags::read_from(buf)?;
tags_vec.push(tags);
}
data.insert(tag_type, tags_vec);
@@ -51,8 +51,8 @@ impl McBufWritable for TagMap {
}
}
impl McBufReadable for Tags {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let name = ResourceLocation::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let name = ResourceLocation::read_from(buf)?;
let elements = buf.read_int_id_list()?;
Ok(Tags { name, elements })
}
diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
index bd2edf38..a06b999b 100755
--- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
@@ -25,7 +25,7 @@ impl ClientboundGameProfilePacket {
}
pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
- let uuid = Uuid::read_into(buf)?;
+ let uuid = Uuid::read_from(buf)?;
let name = buf.read_utf_with_len(16)?;
Ok(ClientboundGameProfilePacket {
game_profile: GameProfile::new(uuid, name),
diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
index 12b7c4ec..7a21736b 100644
--- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -18,13 +18,13 @@ pub enum NonceOrSaltSignature {
}
impl McBufReadable for NonceOrSaltSignature {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let is_nonce = bool::read_into(buf)?;
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
+ let is_nonce = bool::read_from(buf)?;
if is_nonce {
- Ok(NonceOrSaltSignature::Nonce(Vec::<u8>::read_into(buf)?))
+ Ok(NonceOrSaltSignature::Nonce(Vec::<u8>::read_from(buf)?))
} else {
Ok(NonceOrSaltSignature::SaltSignature(
- SaltSignaturePair::read_into(buf)?,
+ SaltSignaturePair::read_from(buf)?,
))
}
}
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index 1c2533e2..2f439cd5 100755
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -51,7 +51,7 @@ where
}
impl azalea_buf::McBufReadable for ConnectionProtocol {
- fn read_into(buf: &mut impl Read) -> Result<Self, String> {
+ fn read_from(buf: &mut impl Read) -> Result<Self, String> {
ConnectionProtocol::from_i32(buf.read_varint()?)
.ok_or_else(|| "Invalid intention".to_string())
}