Add documentation to new public methods for optimizing in-memory.
This commit is contained in:
parent
def47c9c96
commit
bc7de9b734
2 changed files with 4 additions and 2 deletions
|
|
@ -248,7 +248,8 @@ pub fn optimize(filepath: &Path, opts: &Options) -> Result<(), String> {
|
||||||
Ok(())
|
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<Vec<u8>, String> {
|
pub fn optimize_from_memory(data: &[u8], opts: &Options) -> Result<Vec<u8>, String> {
|
||||||
// Read in the file and try to decode as PNG.
|
// Read in the file and try to decode as PNG.
|
||||||
if opts.verbosity.is_some() {
|
if opts.verbosity.is_some() {
|
||||||
|
|
@ -272,7 +273,7 @@ pub fn optimize_from_memory(data: &[u8], opts: &Options) -> Result<Vec<u8>, 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<u8> {
|
fn optimize_png(mut png: &mut png::PngData, file_original_size: usize, opts: &Options) -> Vec<u8> {
|
||||||
type TrialWithData = (u8, u8, u8, u8, Vec<u8>);
|
type TrialWithData = (u8, u8, u8, u8, Vec<u8>);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -306,6 +306,7 @@ impl PngData {
|
||||||
return PngData::from_slice(&byte_data, fix_errors)
|
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<PngData, String> {
|
pub fn from_slice(byte_data: &[u8], fix_errors: bool) -> Result<PngData, String> {
|
||||||
let mut byte_offset: usize = 0;
|
let mut byte_offset: usize = 0;
|
||||||
// Test that png header is valid
|
// Test that png header is valid
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue