From 6f579326b5f48087f2c003e47df68842391e327b Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sun, 3 Nov 2019 21:05:06 -0800 Subject: [PATCH] Cleanup lint. --- src/lib.rs | 48 ++++++------------------------------------------ 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8ea5737..1915579 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,30 +123,12 @@ enum Stream { Data {}, } -impl Stream { - pub fn dimension(&self) -> Option { - None - } -} - #[derive(Clone, Deserialize, Debug, Serialize)] struct Metadata { format: Format, streams: Vec, } -impl Metadata { - pub fn dimension(&self) -> Option { - None - } - pub fn duration(&self) -> f32 { - self.format.duration - } - pub fn size(&self) -> usize { - self.format.size - } -} - #[derive(Clone, Deserialize, Debug, Serialize)] pub struct VideoFormat { short_name: String, @@ -198,6 +180,7 @@ pub struct SubtitleFormat { #[derive(Clone, Deserialize, Debug, Serialize)] pub struct CompactMetadata { bit_rate: usize, + // TODO(wathiede): make this a custom Duration type that pretty prints H:M:S pub duration: f32, filename: String, format_name: String, @@ -470,7 +453,10 @@ impl MovieLibrary { }) } - pub fn videos(&self, include_stale: bool) -> Result<(HashMap), Error> { + pub fn videos( + &self, + _include_stale: bool, + ) -> Result<(HashMap), Error> { // TODO(wathiede): implement include_stale. let path = Path::new(&self.root).join(COMPACT_METADATA_FILENAME); // Open the file in read-only mode with buffer. @@ -483,24 +469,11 @@ impl MovieLibrary { } } -fn read_metadata_from_file>(path: P) -> Result { - let path = path.as_ref(); - // Open the file in read-only mode with buffer. - let f = File::open(path).context(format!("open {}", path.display()))?; - let r = BufReader::new(f); - - // Read the JSON contents of the file as an instance of `User`. - let md = serde_json::from_reader(r) - .context(format!("serde_json::from_reader {}", path.display()))?; - - // Return the `User`. - Ok(md) -} - #[cfg(test)] mod tests { use super::*; + #[allow(dead_code)] fn testdata_dir() -> String { format!("{}/testdata", env::var("CARGO_MANIFEST_DIR").unwrap()) } @@ -547,15 +520,6 @@ mod tests { assert_eq!(md.largest_dimension(), Some(Resolution(640, 480))); } - #[test] - fn test_read_full_metadata() { - let mdf = read_metadata_from_file( - Path::new(&testdata_dir()).join(&format!("Movies/{}", FULL_METADATA_FILENAME)), - ) - .expect("failed to read metadata"); - assert_eq!(mdf.metadata.len(), 1214); - } - /* #[test] fn test_movies() {