From bc7de9b734bf185e2fcee67e5449bafa2aada8c9 Mon Sep 17 00:00:00 2001 From: Toby Lawrence Date: Thu, 5 May 2016 12:18:58 -0400 Subject: [PATCH] Add documentation to new public methods for optimizing in-memory. --- src/lib.rs | 5 +++-- src/png.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 085cce3c..6544ee59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -248,7 +248,8 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), String> { Ok(()) } -/// Perform optimization on the input file using the options provided +/// Perform optimization on the input file using the options provided, where the file is already +/// loaded in-memory pub fn optimize_from_memory(data: &[u8], opts: &Options) -> Result, String> { // Read in the file and try to decode as PNG. if opts.verbosity.is_some() { @@ -272,7 +273,7 @@ pub fn optimize_from_memory(data: &[u8], opts: &Options) -> Result, Stri } } -/// Perform optimization on the input file using the options provided +/// Perform optimization on the input PNG object using the options provided fn optimize_png(mut png: &mut png::PngData, file_original_size: usize, opts: &Options) -> Vec { type TrialWithData = (u8, u8, u8, u8, Vec); diff --git a/src/png.rs b/src/png.rs index c325ab45..2dbecf1e 100644 --- a/src/png.rs +++ b/src/png.rs @@ -306,6 +306,7 @@ impl PngData { return PngData::from_slice(&byte_data, fix_errors) } + /// Create a new `PngData` struct by reading a slice pub fn from_slice(byte_data: &[u8], fix_errors: bool) -> Result { let mut byte_offset: usize = 0; // Test that png header is valid