diff options
| author | Igor Tolmachev <me@igorek.dev> | 2024-07-17 17:38:19 +0900 |
|---|---|---|
| committer | Igor Tolmachev <me@igorek.dev> | 2024-07-17 17:38:19 +0900 |
| commit | 5f4ceda88c7299deb317f8d22a99ab2521c5a380 (patch) | |
| tree | 6b0d7e0ae99376079c599ee897fe73c2e5035420 /src | |
| parent | 2f0f96ce4625d2ef1273c7bea98a1e9415419fdf (diff) | |
| download | archivator-5f4ceda88c7299deb317f8d22a99ab2521c5a380.tar.gz archivator-5f4ceda88c7299deb317f8d22a99ab2521c5a380.zip | |
Add more `#[inline]` markers
Diffstat (limited to 'src')
| -rw-r--r-- | src/error.rs | 2 | ||||
| -rw-r--r-- | src/structs/de.rs | 17 | ||||
| -rw-r--r-- | src/structs/error.rs | 2 | ||||
| -rw-r--r-- | src/structs/ser.rs | 28 | ||||
| -rw-r--r-- | src/zip/cp437.rs | 2 | ||||
| -rw-r--r-- | src/zip/encryption.rs | 22 | ||||
| -rw-r--r-- | src/zip/error.rs | 2 | ||||
| -rw-r--r-- | src/zip/structs.rs | 2 |
8 files changed, 63 insertions, 14 deletions
diff --git a/src/error.rs b/src/error.rs index 518b0e9..b7866d7 100644 --- a/src/error.rs +++ b/src/error.rs | |||
| @@ -8,7 +8,7 @@ pub type ArchiveResult<T, E> = Result<T, ArchiveError<E>>; | |||
| 8 | pub enum ArchiveError<E: Error> { | 8 | pub enum ArchiveError<E: Error> { |
| 9 | Io { error: io::Error }, | 9 | Io { error: io::Error }, |
| 10 | Serde { message: String }, | 10 | Serde { message: String }, |
| 11 | Archivator { module: String, error: E }, | 11 | Archivator { module: &'static str, error: E }, |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | impl<E: Error> From<io::Error> for ArchiveError<E> { | 14 | impl<E: Error> From<io::Error> for ArchiveError<E> { |
diff --git a/src/structs/de.rs b/src/structs/de.rs index 9158d90..edd8011 100644 --- a/src/structs/de.rs +++ b/src/structs/de.rs | |||
| @@ -62,6 +62,7 @@ impl<'a, 'de> EnumDeserializer<'a, 'de> { | |||
| 62 | impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | 62 | impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { |
| 63 | type Error = ArchiveError<StructError>; | 63 | type Error = ArchiveError<StructError>; |
| 64 | 64 | ||
| 65 | #[inline] | ||
| 65 | fn deserialize_any<V>(self, _visitor: V) -> StructResult<V::Value> | 66 | fn deserialize_any<V>(self, _visitor: V) -> StructResult<V::Value> |
| 66 | where | 67 | where |
| 67 | V: de::Visitor<'de>, | 68 | V: de::Visitor<'de>, |
| @@ -154,6 +155,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 154 | visitor.visit_f64(self.settings.byte_order.to_f64(bytes)) | 155 | visitor.visit_f64(self.settings.byte_order.to_f64(bytes)) |
| 155 | } | 156 | } |
| 156 | 157 | ||
| 158 | #[inline] | ||
| 157 | fn deserialize_char<V>(self, _visitor: V) -> StructResult<V::Value> | 159 | fn deserialize_char<V>(self, _visitor: V) -> StructResult<V::Value> |
| 158 | where | 160 | where |
| 159 | V: de::Visitor<'de>, | 161 | V: de::Visitor<'de>, |
| @@ -161,6 +163,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 161 | Err(StructError::DeserializationNotSupported { type_name: "char" }.into()) | 163 | Err(StructError::DeserializationNotSupported { type_name: "char" }.into()) |
| 162 | } | 164 | } |
| 163 | 165 | ||
| 166 | #[inline] | ||
| 164 | fn deserialize_str<V>(self, _visitor: V) -> StructResult<V::Value> | 167 | fn deserialize_str<V>(self, _visitor: V) -> StructResult<V::Value> |
| 165 | where | 168 | where |
| 166 | V: de::Visitor<'de>, | 169 | V: de::Visitor<'de>, |
| @@ -168,6 +171,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 168 | Err(StructError::DeserializationNotSupported { type_name: "str" }.into()) | 171 | Err(StructError::DeserializationNotSupported { type_name: "str" }.into()) |
| 169 | } | 172 | } |
| 170 | 173 | ||
| 174 | #[inline] | ||
| 171 | fn deserialize_string<V>(self, _visitor: V) -> StructResult<V::Value> | 175 | fn deserialize_string<V>(self, _visitor: V) -> StructResult<V::Value> |
| 172 | where | 176 | where |
| 173 | V: de::Visitor<'de>, | 177 | V: de::Visitor<'de>, |
| @@ -178,6 +182,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 178 | .into()) | 182 | .into()) |
| 179 | } | 183 | } |
| 180 | 184 | ||
| 185 | #[inline] | ||
| 181 | fn deserialize_bytes<V>(self, _visitor: V) -> StructResult<V::Value> | 186 | fn deserialize_bytes<V>(self, _visitor: V) -> StructResult<V::Value> |
| 182 | where | 187 | where |
| 183 | V: de::Visitor<'de>, | 188 | V: de::Visitor<'de>, |
| @@ -185,6 +190,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 185 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) | 190 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) |
| 186 | } | 191 | } |
| 187 | 192 | ||
| 193 | #[inline] | ||
| 188 | fn deserialize_byte_buf<V>(self, _visitor: V) -> StructResult<V::Value> | 194 | fn deserialize_byte_buf<V>(self, _visitor: V) -> StructResult<V::Value> |
| 189 | where | 195 | where |
| 190 | V: de::Visitor<'de>, | 196 | V: de::Visitor<'de>, |
| @@ -192,6 +198,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 192 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) | 198 | Err(StructError::DeserializationNotSupported { type_name: "bytes" }.into()) |
| 193 | } | 199 | } |
| 194 | 200 | ||
| 201 | #[inline] | ||
| 195 | fn deserialize_option<V>(self, _visitor: V) -> StructResult<V::Value> | 202 | fn deserialize_option<V>(self, _visitor: V) -> StructResult<V::Value> |
| 196 | where | 203 | where |
| 197 | V: de::Visitor<'de>, | 204 | V: de::Visitor<'de>, |
| @@ -202,6 +209,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 202 | .into()) | 209 | .into()) |
| 203 | } | 210 | } |
| 204 | 211 | ||
| 212 | #[inline] | ||
| 205 | fn deserialize_unit<V>(self, visitor: V) -> StructResult<V::Value> | 213 | fn deserialize_unit<V>(self, visitor: V) -> StructResult<V::Value> |
| 206 | where | 214 | where |
| 207 | V: de::Visitor<'de>, | 215 | V: de::Visitor<'de>, |
| @@ -209,6 +217,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 209 | visitor.visit_unit() | 217 | visitor.visit_unit() |
| 210 | } | 218 | } |
| 211 | 219 | ||
| 220 | #[inline] | ||
| 212 | fn deserialize_unit_struct<V>(self, _name: &'static str, visitor: V) -> StructResult<V::Value> | 221 | fn deserialize_unit_struct<V>(self, _name: &'static str, visitor: V) -> StructResult<V::Value> |
| 213 | where | 222 | where |
| 214 | V: de::Visitor<'de>, | 223 | V: de::Visitor<'de>, |
| @@ -216,6 +225,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 216 | self.deserialize_unit(visitor) | 225 | self.deserialize_unit(visitor) |
| 217 | } | 226 | } |
| 218 | 227 | ||
| 228 | #[inline] | ||
| 219 | fn deserialize_newtype_struct<V>( | 229 | fn deserialize_newtype_struct<V>( |
| 220 | self, | 230 | self, |
| 221 | _name: &'static str, | 231 | _name: &'static str, |
| @@ -227,6 +237,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 227 | visitor.visit_newtype_struct(self) | 237 | visitor.visit_newtype_struct(self) |
| 228 | } | 238 | } |
| 229 | 239 | ||
| 240 | #[inline] | ||
| 230 | fn deserialize_seq<V>(self, _visitor: V) -> StructResult<V::Value> | 241 | fn deserialize_seq<V>(self, _visitor: V) -> StructResult<V::Value> |
| 231 | where | 242 | where |
| 232 | V: de::Visitor<'de>, | 243 | V: de::Visitor<'de>, |
| @@ -234,6 +245,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 234 | Err(StructError::DeserializationNotSupported { type_name: "seq" }.into()) | 245 | Err(StructError::DeserializationNotSupported { type_name: "seq" }.into()) |
| 235 | } | 246 | } |
| 236 | 247 | ||
| 248 | #[inline] | ||
| 237 | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> StructResult<V::Value> | 249 | fn deserialize_tuple<V>(self, len: usize, visitor: V) -> StructResult<V::Value> |
| 238 | where | 250 | where |
| 239 | V: de::Visitor<'de>, | 251 | V: de::Visitor<'de>, |
| @@ -241,6 +253,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 241 | visitor.visit_seq(SeqDeserializer::new(self, len)) | 253 | visitor.visit_seq(SeqDeserializer::new(self, len)) |
| 242 | } | 254 | } |
| 243 | 255 | ||
| 256 | #[inline] | ||
| 244 | fn deserialize_tuple_struct<V>( | 257 | fn deserialize_tuple_struct<V>( |
| 245 | self, | 258 | self, |
| 246 | _name: &'static str, | 259 | _name: &'static str, |
| @@ -253,6 +266,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 253 | self.deserialize_tuple(len, visitor) | 266 | self.deserialize_tuple(len, visitor) |
| 254 | } | 267 | } |
| 255 | 268 | ||
| 269 | #[inline] | ||
| 256 | fn deserialize_map<V>(self, _visitor: V) -> StructResult<V::Value> | 270 | fn deserialize_map<V>(self, _visitor: V) -> StructResult<V::Value> |
| 257 | where | 271 | where |
| 258 | V: de::Visitor<'de>, | 272 | V: de::Visitor<'de>, |
| @@ -260,6 +274,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 260 | Err(StructError::DeserializationNotSupported { type_name: "map" }.into()) | 274 | Err(StructError::DeserializationNotSupported { type_name: "map" }.into()) |
| 261 | } | 275 | } |
| 262 | 276 | ||
| 277 | #[inline] | ||
| 263 | fn deserialize_struct<V>( | 278 | fn deserialize_struct<V>( |
| 264 | self, | 279 | self, |
| 265 | _name: &'static str, | 280 | _name: &'static str, |
| @@ -272,6 +287,7 @@ impl<'de> de::Deserializer<'de> for &mut ArchiveDeserializer<'de> { | |||
| 272 | self.deserialize_tuple(fields.len(), visitor) | 287 | self.deserialize_tuple(fields.len(), visitor) |
| 273 | } | 288 | } |
| 274 | 289 | ||
| 290 | #[inline] | ||
| 275 | fn deserialize_enum<V>( | 291 | fn deserialize_enum<V>( |
| 276 | self, | 292 | self, |
| 277 | _name: &'static str, | 293 | _name: &'static str, |
| @@ -334,6 +350,7 @@ impl<'a, 'de> de::EnumAccess<'de> for EnumDeserializer<'a, 'de> { | |||
| 334 | impl<'a, 'de> de::VariantAccess<'de> for EnumDeserializer<'a, 'de> { | 350 | impl<'a, 'de> de::VariantAccess<'de> for EnumDeserializer<'a, 'de> { |
| 335 | type Error = ArchiveError<StructError>; | 351 | type Error = ArchiveError<StructError>; |
| 336 | 352 | ||
| 353 | #[inline] | ||
| 337 | fn unit_variant(self) -> Result<(), Self::Error> { | 354 | fn unit_variant(self) -> Result<(), Self::Error> { |
| 338 | Ok(()) | 355 | Ok(()) |
| 339 | } | 356 | } |
diff --git a/src/structs/error.rs b/src/structs/error.rs index 3e74e45..f07163c 100644 --- a/src/structs/error.rs +++ b/src/structs/error.rs | |||
| @@ -14,7 +14,7 @@ pub enum StructError { | |||
| 14 | impl From<StructError> for ArchiveError<StructError> { | 14 | impl From<StructError> for ArchiveError<StructError> { |
| 15 | fn from(value: StructError) -> Self { | 15 | fn from(value: StructError) -> Self { |
| 16 | Self::Archivator { | 16 | Self::Archivator { |
| 17 | module: "Struct serializer".to_string(), | 17 | module: "Struct serializer", |
| 18 | error: value, | 18 | error: value, |
| 19 | } | 19 | } |
| 20 | } | 20 | } |
diff --git a/src/structs/ser.rs b/src/structs/ser.rs index 5c26182..f7e694a 100644 --- a/src/structs/ser.rs +++ b/src/structs/ser.rs | |||
| @@ -87,18 +87,22 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 87 | Ok(()) | 87 | Ok(()) |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | #[inline] | ||
| 90 | fn serialize_char(self, _v: char) -> StructResult<()> { | 91 | fn serialize_char(self, _v: char) -> StructResult<()> { |
| 91 | Err(StructError::SerializationNotSupported { type_name: "char" }.into()) | 92 | Err(StructError::SerializationNotSupported { type_name: "char" }.into()) |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 95 | #[inline] | ||
| 94 | fn serialize_str(self, _v: &str) -> StructResult<()> { | 96 | fn serialize_str(self, _v: &str) -> StructResult<()> { |
| 95 | Err(StructError::SerializationNotSupported { type_name: "str" }.into()) | 97 | Err(StructError::SerializationNotSupported { type_name: "str" }.into()) |
| 96 | } | 98 | } |
| 97 | 99 | ||
| 100 | #[inline] | ||
| 98 | fn serialize_bytes(self, _v: &[u8]) -> StructResult<()> { | 101 | fn serialize_bytes(self, _v: &[u8]) -> StructResult<()> { |
| 99 | Err(StructError::SerializationNotSupported { type_name: "bytes" }.into()) | 102 | Err(StructError::SerializationNotSupported { type_name: "bytes" }.into()) |
| 100 | } | 103 | } |
| 101 | 104 | ||
| 105 | #[inline] | ||
| 102 | fn serialize_none(self) -> StructResult<()> { | 106 | fn serialize_none(self) -> StructResult<()> { |
| 103 | Err(StructError::SerializationNotSupported { | 107 | Err(StructError::SerializationNotSupported { |
| 104 | type_name: "optional", | 108 | type_name: "optional", |
| @@ -106,6 +110,7 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 106 | .into()) | 110 | .into()) |
| 107 | } | 111 | } |
| 108 | 112 | ||
| 113 | #[inline] | ||
| 109 | fn serialize_some<T>(self, _value: &T) -> StructResult<()> | 114 | fn serialize_some<T>(self, _value: &T) -> StructResult<()> |
| 110 | where | 115 | where |
| 111 | T: ?Sized + Serialize, | 116 | T: ?Sized + Serialize, |
| @@ -116,10 +121,12 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 116 | .into()) | 121 | .into()) |
| 117 | } | 122 | } |
| 118 | 123 | ||
| 124 | #[inline] | ||
| 119 | fn serialize_unit(self) -> StructResult<()> { | 125 | fn serialize_unit(self) -> StructResult<()> { |
| 120 | Ok(()) | 126 | Ok(()) |
| 121 | } | 127 | } |
| 122 | 128 | ||
| 129 | #[inline] | ||
| 123 | fn serialize_unit_struct(self, _name: &'static str) -> StructResult<()> { | 130 | fn serialize_unit_struct(self, _name: &'static str) -> StructResult<()> { |
| 124 | self.serialize_unit() | 131 | self.serialize_unit() |
| 125 | } | 132 | } |
| @@ -139,6 +146,7 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 139 | Ok(()) | 146 | Ok(()) |
| 140 | } | 147 | } |
| 141 | 148 | ||
| 149 | #[inline] | ||
| 142 | fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> StructResult<()> | 150 | fn serialize_newtype_struct<T>(self, _name: &'static str, value: &T) -> StructResult<()> |
| 143 | where | 151 | where |
| 144 | T: ?Sized + Serialize, | 152 | T: ?Sized + Serialize, |
| @@ -165,14 +173,17 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 165 | value.serialize(self) | 173 | value.serialize(self) |
| 166 | } | 174 | } |
| 167 | 175 | ||
| 176 | #[inline] | ||
| 168 | fn serialize_seq(self, _len: Option<usize>) -> StructResult<Self::SerializeSeq> { | 177 | fn serialize_seq(self, _len: Option<usize>) -> StructResult<Self::SerializeSeq> { |
| 169 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) | 178 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) |
| 170 | } | 179 | } |
| 171 | 180 | ||
| 181 | #[inline] | ||
| 172 | fn serialize_tuple(self, _len: usize) -> StructResult<Self::SerializeTuple> { | 182 | fn serialize_tuple(self, _len: usize) -> StructResult<Self::SerializeTuple> { |
| 173 | Ok(self) | 183 | Ok(self) |
| 174 | } | 184 | } |
| 175 | 185 | ||
| 186 | #[inline] | ||
| 176 | fn serialize_tuple_struct( | 187 | fn serialize_tuple_struct( |
| 177 | self, | 188 | self, |
| 178 | _name: &'static str, | 189 | _name: &'static str, |
| @@ -197,10 +208,12 @@ impl ser::Serializer for &mut ArchiveSerializer { | |||
| 197 | Ok(self) | 208 | Ok(self) |
| 198 | } | 209 | } |
| 199 | 210 | ||
| 211 | #[inline] | ||
| 200 | fn serialize_map(self, _len: Option<usize>) -> StructResult<Self::SerializeMap> { | 212 | fn serialize_map(self, _len: Option<usize>) -> StructResult<Self::SerializeMap> { |
| 201 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) | 213 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) |
| 202 | } | 214 | } |
| 203 | 215 | ||
| 216 | #[inline] | ||
| 204 | fn serialize_struct( | 217 | fn serialize_struct( |
| 205 | self, | 218 | self, |
| 206 | _name: &'static str, | 219 | _name: &'static str, |
| @@ -230,6 +243,7 @@ impl ser::SerializeSeq for &mut ArchiveSerializer { | |||
| 230 | type Ok = (); | 243 | type Ok = (); |
| 231 | type Error = ArchiveError<StructError>; | 244 | type Error = ArchiveError<StructError>; |
| 232 | 245 | ||
| 246 | #[inline] | ||
| 233 | fn serialize_element<T>(&mut self, _value: &T) -> StructResult<()> | 247 | fn serialize_element<T>(&mut self, _value: &T) -> StructResult<()> |
| 234 | where | 248 | where |
| 235 | T: ?Sized + Serialize, | 249 | T: ?Sized + Serialize, |
| @@ -237,6 +251,7 @@ impl ser::SerializeSeq for &mut ArchiveSerializer { | |||
| 237 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) | 251 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) |
| 238 | } | 252 | } |
| 239 | 253 | ||
| 254 | #[inline] | ||
| 240 | fn end(self) -> StructResult<()> { | 255 | fn end(self) -> StructResult<()> { |
| 241 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) | 256 | Err(StructError::SerializationNotSupported { type_name: "seq" }.into()) |
| 242 | } | 257 | } |
| @@ -246,6 +261,7 @@ impl ser::SerializeTuple for &mut ArchiveSerializer { | |||
| 246 | type Ok = (); | 261 | type Ok = (); |
| 247 | type Error = ArchiveError<StructError>; | 262 | type Error = ArchiveError<StructError>; |
| 248 | 263 | ||
| 264 | #[inline] | ||
| 249 | fn serialize_element<T>(&mut self, value: &T) -> StructResult<()> | 265 | fn serialize_element<T>(&mut self, value: &T) -> StructResult<()> |
| 250 | where | 266 | where |
| 251 | T: ?Sized + Serialize, | 267 | T: ?Sized + Serialize, |
| @@ -253,6 +269,7 @@ impl ser::SerializeTuple for &mut ArchiveSerializer { | |||
| 253 | value.serialize(&mut **self) | 269 | value.serialize(&mut **self) |
| 254 | } | 270 | } |
| 255 | 271 | ||
| 272 | #[inline] | ||
| 256 | fn end(self) -> StructResult<()> { | 273 | fn end(self) -> StructResult<()> { |
| 257 | Ok(()) | 274 | Ok(()) |
| 258 | } | 275 | } |
| @@ -262,6 +279,7 @@ impl ser::SerializeTupleStruct for &mut ArchiveSerializer { | |||
| 262 | type Ok = (); | 279 | type Ok = (); |
| 263 | type Error = ArchiveError<StructError>; | 280 | type Error = ArchiveError<StructError>; |
| 264 | 281 | ||
| 282 | #[inline] | ||
| 265 | fn serialize_field<T>(&mut self, value: &T) -> StructResult<()> | 283 | fn serialize_field<T>(&mut self, value: &T) -> StructResult<()> |
| 266 | where | 284 | where |
| 267 | T: ?Sized + Serialize, | 285 | T: ?Sized + Serialize, |
| @@ -269,6 +287,7 @@ impl ser::SerializeTupleStruct for &mut ArchiveSerializer { | |||
| 269 | value.serialize(&mut **self) | 287 | value.serialize(&mut **self) |
| 270 | } | 288 | } |
| 271 | 289 | ||
| 290 | #[inline] | ||
| 272 | fn end(self) -> StructResult<()> { | 291 | fn end(self) -> StructResult<()> { |
| 273 | Ok(()) | 292 | Ok(()) |
| 274 | } | 293 | } |
| @@ -278,6 +297,7 @@ impl ser::SerializeTupleVariant for &mut ArchiveSerializer { | |||
| 278 | type Ok = (); | 297 | type Ok = (); |
| 279 | type Error = ArchiveError<StructError>; | 298 | type Error = ArchiveError<StructError>; |
| 280 | 299 | ||
| 300 | #[inline] | ||
| 281 | fn serialize_field<T>(&mut self, value: &T) -> StructResult<()> | 301 | fn serialize_field<T>(&mut self, value: &T) -> StructResult<()> |
| 282 | where | 302 | where |
| 283 | T: ?Sized + Serialize, | 303 | T: ?Sized + Serialize, |
| @@ -285,6 +305,7 @@ impl ser::SerializeTupleVariant for &mut ArchiveSerializer { | |||
| 285 | value.serialize(&mut **self) | 305 | value.serialize(&mut **self) |
| 286 | } | 306 | } |
| 287 | 307 | ||
| 308 | #[inline] | ||
| 288 | fn end(self) -> StructResult<()> { | 309 | fn end(self) -> StructResult<()> { |
| 289 | Ok(()) | 310 | Ok(()) |
| 290 | } | 311 | } |
| @@ -294,6 +315,7 @@ impl ser::SerializeMap for &mut ArchiveSerializer { | |||
| 294 | type Ok = (); | 315 | type Ok = (); |
| 295 | type Error = ArchiveError<StructError>; | 316 | type Error = ArchiveError<StructError>; |
| 296 | 317 | ||
| 318 | #[inline] | ||
| 297 | fn serialize_key<T>(&mut self, _key: &T) -> StructResult<()> | 319 | fn serialize_key<T>(&mut self, _key: &T) -> StructResult<()> |
| 298 | where | 320 | where |
| 299 | T: ?Sized + Serialize, | 321 | T: ?Sized + Serialize, |
| @@ -301,6 +323,7 @@ impl ser::SerializeMap for &mut ArchiveSerializer { | |||
| 301 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) | 323 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) |
| 302 | } | 324 | } |
| 303 | 325 | ||
| 326 | #[inline] | ||
| 304 | fn serialize_value<T>(&mut self, _value: &T) -> StructResult<()> | 327 | fn serialize_value<T>(&mut self, _value: &T) -> StructResult<()> |
| 305 | where | 328 | where |
| 306 | T: ?Sized + Serialize, | 329 | T: ?Sized + Serialize, |
| @@ -308,6 +331,7 @@ impl ser::SerializeMap for &mut ArchiveSerializer { | |||
| 308 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) | 331 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) |
| 309 | } | 332 | } |
| 310 | 333 | ||
| 334 | #[inline] | ||
| 311 | fn end(self) -> StructResult<()> { | 335 | fn end(self) -> StructResult<()> { |
| 312 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) | 336 | Err(StructError::SerializationNotSupported { type_name: "map" }.into()) |
| 313 | } | 337 | } |
| @@ -317,6 +341,7 @@ impl ser::SerializeStruct for &mut ArchiveSerializer { | |||
| 317 | type Ok = (); | 341 | type Ok = (); |
| 318 | type Error = ArchiveError<StructError>; | 342 | type Error = ArchiveError<StructError>; |
| 319 | 343 | ||
| 344 | #[inline] | ||
| 320 | fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> StructResult<()> | 345 | fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> StructResult<()> |
| 321 | where | 346 | where |
| 322 | T: ?Sized + Serialize, | 347 | T: ?Sized + Serialize, |
| @@ -324,6 +349,7 @@ impl ser::SerializeStruct for &mut ArchiveSerializer { | |||
| 324 | value.serialize(&mut **self) | 349 | value.serialize(&mut **self) |
| 325 | } | 350 | } |
| 326 | 351 | ||
| 352 | #[inline] | ||
| 327 | fn end(self) -> StructResult<()> { | 353 | fn end(self) -> StructResult<()> { |
| 328 | Ok(()) | 354 | Ok(()) |
| 329 | } | 355 | } |
| @@ -333,6 +359,7 @@ impl ser::SerializeStructVariant for &mut ArchiveSerializer { | |||
| 333 | type Ok = (); | 359 | type Ok = (); |
| 334 | type Error = ArchiveError<StructError>; | 360 | type Error = ArchiveError<StructError>; |
| 335 | 361 | ||
| 362 | #[inline] | ||
| 336 | fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> StructResult<()> | 363 | fn serialize_field<T>(&mut self, _key: &'static str, value: &T) -> StructResult<()> |
| 337 | where | 364 | where |
| 338 | T: ?Sized + Serialize, | 365 | T: ?Sized + Serialize, |
| @@ -340,6 +367,7 @@ impl ser::SerializeStructVariant for &mut ArchiveSerializer { | |||
| 340 | value.serialize(&mut **self) | 367 | value.serialize(&mut **self) |
| 341 | } | 368 | } |
| 342 | 369 | ||
| 370 | #[inline] | ||
| 343 | fn end(self) -> StructResult<()> { | 371 | fn end(self) -> StructResult<()> { |
| 344 | Ok(()) | 372 | Ok(()) |
| 345 | } | 373 | } |
diff --git a/src/zip/cp437.rs b/src/zip/cp437.rs index 6f6731a..91a3c00 100644 --- a/src/zip/cp437.rs +++ b/src/zip/cp437.rs | |||
| @@ -343,6 +343,7 @@ pub fn is_cp437(char: char) -> bool { | |||
| 343 | impl FromCp437<Vec<u8>> for String { | 343 | impl FromCp437<Vec<u8>> for String { |
| 344 | type Value = Self; | 344 | type Value = Self; |
| 345 | 345 | ||
| 346 | #[inline] | ||
| 346 | fn from_cp437(bytes: Vec<u8>) -> Self { | 347 | fn from_cp437(bytes: Vec<u8>) -> Self { |
| 347 | Self::from_cp437(bytes.as_slice()) | 348 | Self::from_cp437(bytes.as_slice()) |
| 348 | } | 349 | } |
| @@ -351,6 +352,7 @@ impl FromCp437<Vec<u8>> for String { | |||
| 351 | impl<const S: usize> FromCp437<[u8; S]> for String { | 352 | impl<const S: usize> FromCp437<[u8; S]> for String { |
| 352 | type Value = Self; | 353 | type Value = Self; |
| 353 | 354 | ||
| 355 | #[inline] | ||
| 354 | fn from_cp437(bytes: [u8; S]) -> Self { | 356 | fn from_cp437(bytes: [u8; S]) -> Self { |
| 355 | Self::from_cp437(bytes.as_slice()) | 357 | Self::from_cp437(bytes.as_slice()) |
| 356 | } | 358 | } |
diff --git a/src/zip/encryption.rs b/src/zip/encryption.rs index 76824a1..f317245 100644 --- a/src/zip/encryption.rs +++ b/src/zip/encryption.rs | |||
| @@ -7,22 +7,22 @@ const TABLE: [u32; 256] = generate_table(); | |||
| 7 | const fn generate_table() -> [u32; 256] { | 7 | const fn generate_table() -> [u32; 256] { |
| 8 | let mut table = [0; 256]; | 8 | let mut table = [0; 256]; |
| 9 | 9 | ||
| 10 | let mut b = 0; | 10 | let mut i = 0; |
| 11 | while b <= 255 { | 11 | while i <= 255 { |
| 12 | let mut crc = b as u32; | 12 | let mut t = i as u32; |
| 13 | 13 | ||
| 14 | let mut i = 0; | 14 | let mut j = 0; |
| 15 | while i < 8 { | 15 | while j < 8 { |
| 16 | if (crc & 1) > 0 { | 16 | if (t & 1) > 0 { |
| 17 | crc = (crc >> 1) ^ 0xEDB88320 | 17 | t = (t >> 1) ^ 0xEDB88320 |
| 18 | } else { | 18 | } else { |
| 19 | crc >>= 1 | 19 | t >>= 1 |
| 20 | } | 20 | } |
| 21 | i += 1; | 21 | j += 1; |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | table[b] = crc; | 24 | table[i] = t; |
| 25 | b += 1 | 25 | i += 1 |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | table | 28 | table |
diff --git a/src/zip/error.rs b/src/zip/error.rs index 525a67b..5573cf8 100644 --- a/src/zip/error.rs +++ b/src/zip/error.rs | |||
| @@ -29,7 +29,7 @@ pub enum ZipError { | |||
| 29 | impl From<ZipError> for ArchiveError<ZipError> { | 29 | impl From<ZipError> for ArchiveError<ZipError> { |
| 30 | fn from(value: ZipError) -> Self { | 30 | fn from(value: ZipError) -> Self { |
| 31 | Self::Archivator { | 31 | Self::Archivator { |
| 32 | module: "Zip".to_string(), | 32 | module: "Zip", |
| 33 | error: value, | 33 | error: value, |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
diff --git a/src/zip/structs.rs b/src/zip/structs.rs index 9fd1aeb..ebecae7 100644 --- a/src/zip/structs.rs +++ b/src/zip/structs.rs | |||
| @@ -58,11 +58,13 @@ pub struct ExtraHeader { | |||
| 58 | pub size: u16, | 58 | pub size: u16, |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | #[inline] | ||
| 61 | #[allow(dead_code)] | 62 | #[allow(dead_code)] |
| 62 | pub fn serialize<T: Serialize>(object: &mut T) -> StructResult<Vec<u8>> { | 63 | pub fn serialize<T: Serialize>(object: &mut T) -> StructResult<Vec<u8>> { |
| 63 | Settings::new(ByteOrder::Le, VariantIndexType::U8).serialize(object) | 64 | Settings::new(ByteOrder::Le, VariantIndexType::U8).serialize(object) |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 67 | #[inline] | ||
| 66 | pub fn deserialize<'de, T: Deserialize<'de>>(object: &'de [u8]) -> StructResult<T> { | 68 | pub fn deserialize<'de, T: Deserialize<'de>>(object: &'de [u8]) -> StructResult<T> { |
| 67 | Settings::new(ByteOrder::Le, VariantIndexType::U8).deserialize(object) | 69 | Settings::new(ByteOrder::Le, VariantIndexType::U8).deserialize(object) |
| 68 | } | 70 | } |
