mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-09 22:14:59 +00:00
Remove unused code
This commit is contained in:
parent
b938b09901
commit
c544f167fb
4 changed files with 5 additions and 104 deletions
|
@ -9,9 +9,6 @@ pub(crate) enum ExifError {
|
||||||
#[error("Error in process")]
|
#[error("Error in process")]
|
||||||
Process(#[source] ProcessError),
|
Process(#[source] ProcessError),
|
||||||
|
|
||||||
#[error("Error reading process output")]
|
|
||||||
Read(#[source] std::io::Error),
|
|
||||||
|
|
||||||
#[error("Invalid media file provided")]
|
#[error("Invalid media file provided")]
|
||||||
CommandFailed(ProcessError),
|
CommandFailed(ProcessError),
|
||||||
}
|
}
|
||||||
|
@ -29,16 +26,15 @@ impl ExifError {
|
||||||
pub(crate) const fn error_code(&self) -> ErrorCode {
|
pub(crate) const fn error_code(&self) -> ErrorCode {
|
||||||
match self {
|
match self {
|
||||||
Self::Process(e) => e.error_code(),
|
Self::Process(e) => e.error_code(),
|
||||||
Self::Read(_) => ErrorCode::COMMAND_ERROR,
|
|
||||||
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
|
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub(crate) fn is_client_error(&self) -> bool {
|
pub(crate) fn is_client_error(&self) -> bool {
|
||||||
// if exiftool bails we probably have bad input
|
// if exiftool bails we probably have bad input
|
||||||
matches!(
|
match self {
|
||||||
self,
|
Self::CommandFailed(_) => true,
|
||||||
Self::CommandFailed(_) | Self::Process(ProcessError::Timeout(_))
|
Self::Process(e) => e.is_client_error(),
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,6 @@ pub(crate) enum FfMpegError {
|
||||||
#[error("Error in ffmpeg process")]
|
#[error("Error in ffmpeg process")]
|
||||||
Process(#[source] ProcessError),
|
Process(#[source] ProcessError),
|
||||||
|
|
||||||
#[error("Error reading output")]
|
|
||||||
Read(#[source] std::io::Error),
|
|
||||||
|
|
||||||
#[error("Error writing bytes")]
|
#[error("Error writing bytes")]
|
||||||
Write(#[source] std::io::Error),
|
Write(#[source] std::io::Error),
|
||||||
|
|
||||||
|
@ -51,8 +48,7 @@ impl FfMpegError {
|
||||||
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
|
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
|
||||||
Self::Store(s) => s.error_code(),
|
Self::Store(s) => s.error_code(),
|
||||||
Self::Process(e) => e.error_code(),
|
Self::Process(e) => e.error_code(),
|
||||||
Self::Read(_)
|
Self::Write(_)
|
||||||
| Self::Write(_)
|
|
||||||
| Self::Json(_)
|
| Self::Json(_)
|
||||||
| Self::CreateDir(_)
|
| Self::CreateDir(_)
|
||||||
| Self::ReadFile(_)
|
| Self::ReadFile(_)
|
||||||
|
|
|
@ -23,9 +23,6 @@ pub(crate) enum MagickError {
|
||||||
#[error("Invalid output format")]
|
#[error("Invalid output format")]
|
||||||
Json(#[source] serde_json::Error),
|
Json(#[source] serde_json::Error),
|
||||||
|
|
||||||
#[error("Error reading bytes")]
|
|
||||||
Read(#[source] std::io::Error),
|
|
||||||
|
|
||||||
#[error("Error writing bytes")]
|
#[error("Error writing bytes")]
|
||||||
Write(#[source] std::io::Error),
|
Write(#[source] std::io::Error),
|
||||||
|
|
||||||
|
@ -67,7 +64,6 @@ impl MagickError {
|
||||||
Self::Store(e) => e.error_code(),
|
Self::Store(e) => e.error_code(),
|
||||||
Self::Process(e) => e.error_code(),
|
Self::Process(e) => e.error_code(),
|
||||||
Self::Json(_)
|
Self::Json(_)
|
||||||
| Self::Read(_)
|
|
||||||
| Self::Write(_)
|
| Self::Write(_)
|
||||||
| Self::CreateFile(_)
|
| Self::CreateFile(_)
|
||||||
| Self::CreateDir(_)
|
| Self::CreateDir(_)
|
||||||
|
@ -185,33 +181,6 @@ pub(crate) async fn process_image_store_read<S: Store + 'static>(
|
||||||
.await
|
.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(
|
pub(crate) async fn process_image_process_read(
|
||||||
tmp_dir: &TmpDir,
|
tmp_dir: &TmpDir,
|
||||||
process_read: ProcessRead,
|
process_read: ProcessRead,
|
||||||
|
|
|
@ -67,15 +67,6 @@ impl Drop for TmpDir {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub(crate) struct TmpFolder(Arc<Path>);
|
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 {
|
impl AsRef<Path> for TmpFolder {
|
||||||
fn as_ref(&self) -> &Path {
|
fn as_ref(&self) -> &Path {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -102,15 +93,6 @@ impl Drop for TmpFolder {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub(crate) struct TmpFile(Arc<Path>);
|
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 {
|
impl AsRef<Path> for TmpFile {
|
||||||
fn as_ref(&self) -> &Path {
|
fn as_ref(&self) -> &Path {
|
||||||
&self.0
|
&self.0
|
||||||
|
@ -130,45 +112,3 @@ impl Drop for TmpFile {
|
||||||
crate::sync::spawn("remove-tmpfile", tokio::fs::remove_file(self.0.clone()));
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue