diff --git a/msg_tool_macro/src/lib.rs b/msg_tool_macro/src/lib.rs index 19f1fba..1c86fcc 100644 --- a/msg_tool_macro/src/lib.rs +++ b/msg_tool_macro/src/lib.rs @@ -60,7 +60,7 @@ pub fn struct_unpack_impl_for_num(item: TokenStream) -> TokenStream { } /// Macro to derive `StructPack` trait for structs. -/// +/// /// make sure to import the necessary imports: /// ``` /// use crate::ext::io::*; @@ -77,7 +77,10 @@ pub fn struct_unpack_impl_for_num(item: TokenStream) -> TokenStream { /// * `pvec()` attribute can be used to specify a packed vector length for Vec<_> fields, where `` can be `u8`, `u16`, `u32`, or `u64`. /// Length is read as a prefix before the vector data. /// * `skip_pack_if()` attribute can be used to skip packing a field if the expression evaluates to true. The expression must be a valid Rust expression that evaluates to a boolean. -#[proc_macro_derive(StructPack, attributes(skip_pack, fstring, fstring_pad, fvec, pstring, pvec, skip_pack_if))] +#[proc_macro_derive( + StructPack, + attributes(skip_pack, fstring, fstring_pad, fvec, pstring, pvec, skip_pack_if) +)] pub fn struct_pack_derive(input: TokenStream) -> TokenStream { let a = syn::parse_macro_input!(input as PackStruct); match a { @@ -452,14 +455,14 @@ pub fn struct_pack_derive(input: TokenStream) -> TokenStream { } /// Macro to derive `StructUnpack` trait for structs. -/// +/// /// make sure to import the necessary imports: /// ``` /// use crate::ext::io::*; /// use crate::utils::struct_pack::*; /// use std::io::{Read, Seek, Write}; /// ``` -/// +/// /// * `skip_unpack` attribute can be used to skip fields from unpacking. /// * `fstring = ` attribute can be used to specify a fixed string length for String fields. /// * `fstring_no_trim` attribute can be used to disable trimming of fixed strings. @@ -469,7 +472,18 @@ pub fn struct_pack_derive(input: TokenStream) -> TokenStream { /// * `pvec()` attribute can be used to specify a packed vector length for Vec<_> fields, where `` can be `u8`, `u16`, `u32` or `u64`. /// length is read as a prefix before the vector data. /// * `skip_unpack_if()` attribute can be used to skip unpacking a field if the expression evaluates to true. The expression must be a valid Rust expression that evaluates to a boolean. -#[proc_macro_derive(StructUnpack, attributes(skip_unpack, fstring, fstring_no_trim, fvec, pstring, pvec, skip_unpack_if))] +#[proc_macro_derive( + StructUnpack, + attributes( + skip_unpack, + fstring, + fstring_no_trim, + fvec, + pstring, + pvec, + skip_unpack_if + ) +)] pub fn struct_unpack_derive(input: TokenStream) -> TokenStream { let sut = syn::parse_macro_input!(input as syn::ItemStruct); let name = sut.ident; diff --git a/src/ext/io.rs b/src/ext/io.rs index 98abd13..32595e8 100644 --- a/src/ext/io.rs +++ b/src/ext/io.rs @@ -926,7 +926,7 @@ pub trait SeekExt { fn stream_length(&mut self) -> Result; } -impl SeekExt for T{ +impl SeekExt for T { fn stream_length(&mut self) -> Result { let current_pos = self.stream_position()?; let length = self.seek(SeekFrom::End(0))?; diff --git a/src/scripts/circus/image/crx.rs b/src/scripts/circus/image/crx.rs index d8e88cf..09d3a63 100644 --- a/src/scripts/circus/image/crx.rs +++ b/src/scripts/circus/image/crx.rs @@ -141,7 +141,7 @@ impl CrxImage { }) } - fn decode_row0( + fn decode_row0( dst: &mut Vec, mut dst_p: usize, src: &[u8], @@ -352,7 +352,9 @@ impl Script for CrxImage { } fn export_image(&self) -> Result { - let data_size = self.color_type.bpp(1) as usize * self.header.width as usize * self.header.height as usize; + let data_size = self.color_type.bpp(1) as usize + * self.header.width as usize + * self.header.height as usize; let mut data = vec![0; data_size]; let mut encode_type = Vec::new(); Self::decode_image( @@ -364,11 +366,7 @@ impl Script for CrxImage { &mut encode_type, )?; if self.color_type.bpp(1) == 4 && self.header.mode != 1 { - let alpha_flip = if self.header.mode == 2 { - 0 - } else { - 0xFF - }; + let alpha_flip = if self.header.mode == 2 { 0 } else { 0xFF }; for i in (0..data_size).step_by(4) { let a = data[i]; let b = data[i + 1];