From 9243010cc023f5348791060fa57ce85a9cb7dc32 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 11 Feb 2021 01:50:22 +0100 Subject: [PATCH] swf: Clean up a few imports --- swf/src/error.rs | 14 +++----------- swf/src/read.rs | 4 ++-- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/swf/src/error.rs b/swf/src/error.rs index 14c8bf3ab..4be22a8ab 100644 --- a/swf/src/error.rs +++ b/swf/src/error.rs @@ -1,4 +1,5 @@ use std::{borrow, error, fmt, io}; +use crate::tag_code::TagCode; /// A `Result` from reading SWF data. pub type Result = std::result::Result; @@ -51,14 +52,6 @@ impl Error { } /// Helper method to create `Error::SwfParseError`. #[inline] - pub fn swf_parse_error(tag_code: u16) -> Self { - Error::SwfParseError { - tag_code, - source: None, - } - } - /// Helper method to create `Error::SwfParseError`. - #[inline] pub fn swf_parse_error_with_source(tag_code: u16, source: impl error::Error + 'static) -> Self { Error::SwfParseError { tag_code, @@ -90,10 +83,9 @@ impl fmt::Display for Error { Ok(()) } Error::SwfParseError { tag_code, source } => { - let tag = crate::tag_code::TagCode::from_u16(*tag_code); "Error parsing SWF tag ".fmt(f)?; - if let Some(tag) = tag { - write!(f, "{:?}", tag)?; + if let Some(tag_code) = TagCode::from_u16(*tag_code) { + write!(f, "{:?}", tag_code)?; } else { write!(f, "Unknown({})", tag_code)?; }; diff --git a/swf/src/read.rs b/swf/src/read.rs index 5fbbc5e04..11ac6bf56 100644 --- a/swf/src/read.rs +++ b/swf/src/read.rs @@ -10,6 +10,7 @@ use crate::extensions::ReadSwfExt; use crate::{ error::{Error, Result}, string::{Encoding, SwfStr}, + tag_code::TagCode, types::*, }; use bitstream_io::BitRead; @@ -308,7 +309,6 @@ impl<'a> Reader<'a> { fn read_tag_with_code(&mut self, tag_code: u16, length: usize) -> Result> { let mut tag_reader = Reader::new(self.read_slice(length)?, self.version); - use crate::tag_code::TagCode; let tag = match TagCode::from_u16(tag_code) { Some(TagCode::End) => Tag::End, Some(TagCode::ShowFrame) => Tag::ShowFrame, @@ -552,7 +552,7 @@ impl<'a> Reader<'a> { Some(TagCode::VideoFrame) => tag_reader.read_video_frame()?, Some(TagCode::ProductInfo) => Tag::ProductInfo(tag_reader.read_product_info()?), - _ => { + None => { let data = tag_reader.read_slice_to_end(); Tag::Unknown { tag_code, data } }