Skip to content

Commit

Permalink
rust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
theaddonn committed Aug 3, 2024
1 parent 5c99d6b commit da9472a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
7 changes: 5 additions & 2 deletions crates/proto/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,12 @@ impl Connection {
};

let pos = decrypted_stream.position() as usize;

compression
.decompress(&decrypted_stream.into_inner()[pos..], &mut decompressed_stream)
.decompress(
&decrypted_stream.into_inner()[pos..],
&mut decompressed_stream,
)
.map_err(|e| ConnectionError::CompressError(e))?;

Cursor::new(decompressed_stream.as_slice())
Expand Down
5 changes: 4 additions & 1 deletion crates/proto/src/gamepacket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,10 @@ impl GamePacket {
VAR::<u32>::proto_deserialize(stream)?;

// Read the game packet header and parse it into an u16
let game_packet_header: u16 = VAR::<u32>::proto_deserialize(stream)?.into_inner().try_into().map_err(ProtoCodecError::FromIntError)?;
let game_packet_header: u16 = VAR::<u32>::proto_deserialize(stream)?
.into_inner()
.try_into()
.map_err(ProtoCodecError::FromIntError)?;

// Get the first 10 bits as the packet id
// Can never be more than a 16-bit integer due to being 10-bits big
Expand Down
4 changes: 1 addition & 3 deletions crates/proto/src/login/provider/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ impl DefaultLoginProvider {

impl LoginProviderServer for DefaultLoginProvider {
fn compression(&self) -> Compression {
Compression::Snappy {
threshold: 1,
}
Compression::Snappy { threshold: 1 }
}
fn encryption_enabled(&self) -> bool {
false
Expand Down
5 changes: 3 additions & 2 deletions crates/proto/src/packets/level_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ impl ProtoCodec for LevelChunkPacket {
unimplemented!()
}

let len = self.serialized_chunk_data
let len = self
.serialized_chunk_data
.len()
.try_into()
.map_err(ProtoCodecError::FromIntError)?;
Expand All @@ -50,7 +51,7 @@ impl ProtoCodec for LevelChunkPacket {
stream.extend_from_slice(&self.serialized_chunk_data);

println!("finish");

Ok(())
}

Expand Down
10 changes: 4 additions & 6 deletions crates/proto/src/packets/text_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,10 @@ impl ProtoCodec for TextMessagePacket {

let message_type = match message_type {
0 => TextMessageData::Raw(String::proto_deserialize(stream)?),
1 => {
TextMessageData::Chat {
player_name: String::proto_deserialize(stream)?,
message: String::proto_deserialize(stream)?,
}
}
1 => TextMessageData::Chat {
player_name: String::proto_deserialize(stream)?,
message: String::proto_deserialize(stream)?,
},
2 => {
let message = String::proto_deserialize(stream)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/proto/src/types/disconnect_reason.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bedrockrs_proto_derive::ProtoCodec;
use bedrockrs_core::int::VAR;
use bedrockrs_proto_derive::ProtoCodec;

#[derive(ProtoCodec, Debug, Clone)]
#[enum_repr(VAR::<i32>)]
Expand Down
8 changes: 2 additions & 6 deletions crates/proto/src/types/gamerule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,8 @@ impl ProtoCodec for GameRuleValue {
.into_inner()
{
1 => GameRuleValue::ValBool(bool::proto_deserialize(stream)?),
2 => GameRuleValue::ValVarU32(
VAR::<u32>::proto_deserialize(stream)?.into_inner(),
),
3 => GameRuleValue::ValF32(
LE::<f32>::proto_deserialize(stream)?.into_inner(),
),
2 => GameRuleValue::ValVarU32(VAR::<u32>::proto_deserialize(stream)?.into_inner()),
3 => GameRuleValue::ValF32(LE::<f32>::proto_deserialize(stream)?.into_inner()),
other => {
return Err(ProtoCodecError::InvalidEnumID(
format!("{other:?}"),
Expand Down

0 comments on commit da9472a

Please sign in to comment.