2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Remove unused code

This commit is contained in:
asonix 2023-12-22 21:00:37 -06:00
parent b938b09901
commit c544f167fb
4 changed files with 5 additions and 104 deletions

View file

@ -9,9 +9,6 @@ pub(crate) enum ExifError {
#[error("Error in process")]
Process(#[source] ProcessError),
#[error("Error reading process output")]
Read(#[source] std::io::Error),
#[error("Invalid media file provided")]
CommandFailed(ProcessError),
}
@ -29,16 +26,15 @@ impl ExifError {
pub(crate) const fn error_code(&self) -> ErrorCode {
match self {
Self::Process(e) => e.error_code(),
Self::Read(_) => ErrorCode::COMMAND_ERROR,
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
}
}
pub(crate) fn is_client_error(&self) -> bool {
// if exiftool bails we probably have bad input
matches!(
self,
Self::CommandFailed(_) | Self::Process(ProcessError::Timeout(_))
)
match self {
Self::CommandFailed(_) => true,
Self::Process(e) => e.is_client_error(),
}
}
}

View file

@ -5,9 +5,6 @@ pub(crate) enum FfMpegError {
#[error("Error in ffmpeg process")]
Process(#[source] ProcessError),
#[error("Error reading output")]
Read(#[source] std::io::Error),
#[error("Error writing bytes")]
Write(#[source] std::io::Error),
@ -51,8 +48,7 @@ impl FfMpegError {
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
Self::Store(s) => s.error_code(),
Self::Process(e) => e.error_code(),
Self::Read(_)
| Self::Write(_)
Self::Write(_)
| Self::Json(_)
| Self::CreateDir(_)
| Self::ReadFile(_)

View file

@ -23,9 +23,6 @@ pub(crate) enum MagickError {
#[error("Invalid output format")]
Json(#[source] serde_json::Error),
#[error("Error reading bytes")]
Read(#[source] std::io::Error),
#[error("Error writing bytes")]
Write(#[source] std::io::Error),
@ -67,7 +64,6 @@ impl MagickError {
Self::Store(e) => e.error_code(),
Self::Process(e) => e.error_code(),
Self::Json(_)
| Self::Read(_)
| Self::Write(_)
| Self::CreateFile(_)
| Self::CreateDir(_)
@ -185,33 +181,6 @@ pub(crate) async fn process_image_store_read<S: Store + 'static>(
.await
}
pub(crate) async fn process_image_async_read<A: AsyncRead + Unpin + 'static>(
tmp_dir: &TmpDir,
async_read: A,
args: Vec<String>,
input_format: ProcessableFormat,
format: ProcessableFormat,
quality: Option<u8>,
timeout: u64,
) -> Result<ProcessRead, MagickError> {
process_image(
tmp_dir,
args,
input_format,
format,
quality,
timeout,
|mut tmp_file| async move {
tmp_file
.write_from_async_read(async_read)
.await
.map_err(MagickError::Write)?;
Ok(tmp_file)
},
)
.await
}
pub(crate) async fn process_image_process_read(
tmp_dir: &TmpDir,
process_read: ProcessRead,

View file

@ -67,15 +67,6 @@ impl Drop for TmpDir {
#[must_use]
pub(crate) struct TmpFolder(Arc<Path>);
impl TmpFolder {
pub(crate) fn reader<R: AsyncRead>(self, reader: R) -> TmpFolderCleanup<R> {
TmpFolderCleanup {
inner: reader,
folder: self,
}
}
}
impl AsRef<Path> for TmpFolder {
fn as_ref(&self) -> &Path {
&self.0
@ -102,15 +93,6 @@ impl Drop for TmpFolder {
#[must_use]
pub(crate) struct TmpFile(Arc<Path>);
impl TmpFile {
pub(crate) fn reader<R: AsyncRead>(self, reader: R) -> TmpFileCleanup<R> {
TmpFileCleanup {
inner: reader,
file: self,
}
}
}
impl AsRef<Path> for TmpFile {
fn as_ref(&self) -> &Path {
&self.0
@ -130,45 +112,3 @@ impl Drop for TmpFile {
crate::sync::spawn("remove-tmpfile", tokio::fs::remove_file(self.0.clone()));
}
}
pin_project_lite::pin_project! {
pub(crate) struct TmpFileCleanup<R> {
#[pin]
inner: R,
file: TmpFile,
}
}
pin_project_lite::pin_project! {
pub(crate) struct TmpFolderCleanup<R> {
#[pin]
inner: R,
folder: TmpFolder,
}
}
impl<R: AsyncRead> AsyncRead for TmpFileCleanup<R> {
fn poll_read(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &mut tokio::io::ReadBuf<'_>,
) -> std::task::Poll<std::io::Result<()>> {
let this = self.as_mut().project();
this.inner.poll_read(cx, buf)
}
}
impl<R: AsyncRead> AsyncRead for TmpFolderCleanup<R> {
fn poll_read(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
buf: &mut tokio::io::ReadBuf<'_>,
) -> std::task::Poll<std::io::Result<()>> {
let this = self.as_mut().project();
this.inner.poll_read(cx, buf)
}
}