From 6c94102afc70ce28eee3d17aad997a056aaf9195 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Fri, 11 Oct 2024 19:01:52 -0400 Subject: gltf, wav, and binary codecs --- src/jpeg/segment.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/jpeg/segment.rs') diff --git a/src/jpeg/segment.rs b/src/jpeg/segment.rs index cd1a651..c0512a1 100644 --- a/src/jpeg/segment.rs +++ b/src/jpeg/segment.rs @@ -2,7 +2,7 @@ use std::{mem::size_of, usize}; use img_parts::jpeg::{markers, Jpeg, JpegSegment}; -use crate::{codec::Codec, CodecError}; +use crate::{codec::Codec, Error}; /// Codec for storing payload data in JPEG comment (COM) segments. Can store an arbitrary amount of /// data, as long as the number of comment segments does not exceed u64::MAX. @@ -13,11 +13,11 @@ pub struct JpegSegmentCodec { } impl Codec for JpegSegmentCodec { - fn encode(&self, carrier: &[u8], payload: &[u8]) -> Result, CodecError> + fn encode(&self, carrier: &[u8], payload: &[u8]) -> Result, Error> { let mut jpeg = match Jpeg::from_bytes(carrier.to_vec().into()) { Ok(v) => v, - Err(e) => return Err(CodecError::DependencyError(e.to_string())) + Err(e) => return Err(Error::DependencyError(e.to_string())) }; let mut payload_bytes = payload.to_vec(); let segment_count = ((payload_bytes.len() + size_of::()) as u64).div_ceil((u16::MAX as usize - size_of::()) as u64); @@ -29,11 +29,11 @@ impl Codec for JpegSegmentCodec { Ok(jpeg.encoder().bytes().to_vec()) } - fn decode(&self, encoded: &[u8]) -> Result<(Vec, Vec), CodecError> + fn decode(&self, encoded: &[u8]) -> Result<(Vec, Vec), Error> { let mut jpeg = match Jpeg::from_bytes(encoded.to_vec().into()) { Ok(v) => v, - Err(e) => return Err(CodecError::DependencyError(e.to_string())) + Err(e) => return Err(Error::DependencyError(e.to_string())) }; let segment = jpeg.segments_mut().remove(self.start_index); let segment_bytes = segment.contents(); -- cgit v1.2.3