From 0b28b249000a3342f2d3434fc2bc51de415a5599 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sun, 12 May 2024 13:14:33 +0200 Subject: [PATCH] cargo fmt --- src/bit_vec.rs | 4 +++- src/command.rs | 10 +++++----- src/command_code.rs | 2 +- src/compression.rs | 4 ++-- src/compression_code.rs | 2 +- src/lib.rs | 6 +++--- src/pixel_grid.rs | 1 - 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/bit_vec.rs b/src/bit_vec.rs index a6fa9ab..2c01fea 100644 --- a/src/bit_vec.rs +++ b/src/bit_vec.rs @@ -91,7 +91,9 @@ impl Into> for BitVec { impl From<&[u8]> for BitVec { fn from(value: &[u8]) -> Self { - Self { data: Vec::from(value) } + Self { + data: Vec::from(value), + } } } diff --git a/src/command.rs b/src/command.rs index bde2f3a..aec6c36 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,5 +1,8 @@ -use crate::{BitVec, ByteGrid, CommandCode, CompressionCode, Header, Packet, PixelGrid, TILE_SIZE}; use crate::compression::{into_compressed, into_decompressed}; +use crate::{ + BitVec, ByteGrid, CommandCode, CompressionCode, Header, Packet, PixelGrid, + TILE_SIZE, +}; /// An origin marks the top left position of a window sent to the display. #[derive(Debug, Clone, Copy)] @@ -266,10 +269,7 @@ fn origin_size_payload( } fn command_code_only(code: CommandCode) -> Packet { - Packet( - Header(code.into(), 0x0000, 0x0000, 0x0000, 0x0000), - vec![], - ) + Packet(Header(code.into(), 0x0000, 0x0000, 0x0000, 0x0000), vec![]) } fn check_empty_header(header: Header) -> Option { diff --git a/src/command_code.rs b/src/command_code.rs index 22f1156..4a9bff9 100644 --- a/src/command_code.rs +++ b/src/command_code.rs @@ -43,7 +43,7 @@ impl TryFrom for CommandCode { value if value == BitmapLinearAnd as u16 => Ok(BitmapLinearAnd), value if value == BitmapLinearOr as u16 => Ok(BitmapLinearOr), value if value == BitmapLinearXor as u16 => Ok(BitmapLinearXor), - _ => Err(()) + _ => Err(()), } } } diff --git a/src/compression.rs b/src/compression.rs index af53bd9..0fd0df7 100644 --- a/src/compression.rs +++ b/src/compression.rs @@ -1,11 +1,11 @@ -#[cfg(feature = "compression")] -use std::io::{Read, Write}; #[cfg(feature = "compression-bz")] use bzip2::read::{BzDecoder, BzEncoder}; #[cfg(feature = "compression-gz")] use flate2::read::{GzDecoder, GzEncoder}; #[cfg(feature = "compression-lz")] use lz4::{Decoder as Lz4Decoder, EncoderBuilder as Lz4EncoderBuilder}; +#[cfg(feature = "compression")] +use std::io::{Read, Write}; #[cfg(feature = "compression-zs")] use zstd::{Decoder as ZstdDecoder, Encoder as ZstdEncoder}; diff --git a/src/compression_code.rs b/src/compression_code.rs index 52b0982..31f121d 100644 --- a/src/compression_code.rs +++ b/src/compression_code.rs @@ -35,7 +35,7 @@ impl TryFrom for CompressionCode { value if value == Lz as u16 => Ok(Lz), #[cfg(feature = "compression-zs")] value if value == Zs as u16 => Ok(Zs), - _ => Err(()) + _ => Err(()), } } } diff --git a/src/lib.rs b/src/lib.rs index 9bcde8c..a342a35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,21 +1,21 @@ pub use crate::bit_vec::BitVec; pub use crate::byte_grid::ByteGrid; pub use crate::command::{Command, Origin, Size}; +pub use crate::command_code::CommandCode; +pub use crate::compression_code::CompressionCode; pub use crate::connection::Connection; pub use crate::packet::{Header, Packet, Payload}; pub use crate::pixel_grid::PixelGrid; -pub use crate::command_code::CommandCode; -pub use crate::compression_code::CompressionCode; mod bit_vec; mod byte_grid; mod command; mod command_code; mod compression; +mod compression_code; mod connection; mod packet; mod pixel_grid; -mod compression_code; /// size of a single tile in one dimension pub const TILE_SIZE: u16 = 8; diff --git a/src/pixel_grid.rs b/src/pixel_grid.rs index e81a3a2..68e7af1 100644 --- a/src/pixel_grid.rs +++ b/src/pixel_grid.rs @@ -11,7 +11,6 @@ pub struct PixelGrid { } impl PixelGrid { - /// Creates a new pixel grid with the specified dimensions. /// /// # Arguments