summaryrefslogtreecommitdiff
path: root/src/jpeg
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <[email protected]>2024-10-11 19:01:52 -0400
committerLibravatar Silas Bartha <[email protected]>2024-10-11 19:01:52 -0400
commit6c94102afc70ce28eee3d17aad997a056aaf9195 (patch)
tree11232fc59c356ce4f3b52cb140d779a3f1dc2006 /src/jpeg
parent5b5f1bed5e8da9d799e5910793477ba0360d5135 (diff)
gltf, wav, and binary codecsv0.3.0
Diffstat (limited to 'src/jpeg')
-rw-r--r--src/jpeg/segment.rs10
1 files changed, 5 insertions, 5 deletions
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<Vec<u8>, CodecError>
+ fn encode(&self, carrier: &[u8], payload: &[u8]) -> Result<Vec<u8>, 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::<u64>()) as u64).div_ceil((u16::MAX as usize - size_of::<u16>()) as u64);
@@ -29,11 +29,11 @@ impl Codec for JpegSegmentCodec {
Ok(jpeg.encoder().bytes().to_vec())
}
- fn decode(&self, encoded: &[u8]) -> Result<(Vec<u8>, Vec<u8>), CodecError>
+ fn decode(&self, encoded: &[u8]) -> Result<(Vec<u8>, Vec<u8>), 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();