aboutsummaryrefslogtreecommitdiffstats
path: root/crates/yt_dlp/src/error.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-13 20:54:49 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-06-13 20:56:40 +0200
commit69145b4deed4fe512239a9f88e6af69d3b8c0309 (patch)
tree7643edd350c1cec75f91e0982ffd3c840f8661fb /crates/yt_dlp/src/error.rs
parentbuild(treewide): Update (diff)
downloadyt-69145b4deed4fe512239a9f88e6af69d3b8c0309.zip
feat({yt_dlp,yt}): Migrate from pyo3 to rustpython
That allows us to avoid cpython's GIL and gives us full ability to leverage async/concurrent code to speed up python operations. I have also taken the opportunity to change the `InfoJson` struct to an untyped json value, as that is what it actually is.
Diffstat (limited to 'crates/yt_dlp/src/error.rs')
-rw-r--r--crates/yt_dlp/src/error.rs68
1 files changed, 0 insertions, 68 deletions
diff --git a/crates/yt_dlp/src/error.rs b/crates/yt_dlp/src/error.rs
deleted file mode 100644
index 3881f0b..0000000
--- a/crates/yt_dlp/src/error.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-// yt - A fully featured command line YouTube client
-//
-// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
-// SPDX-License-Identifier: GPL-3.0-or-later
-//
-// This file is part of Yt.
-//
-// You should have received a copy of the License along with this program.
-// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
-
-use std::{fmt::Display, io};
-
-use pyo3::Python;
-
-#[derive(Debug)]
-#[allow(clippy::module_name_repetitions)]
-pub enum YtDlpError {
- ResponseParseError {
- error: serde_json::error::Error,
- },
- PythonError {
- error: Box<pyo3::PyErr>,
- kind: String,
- },
- IoError {
- error: io::Error,
- },
-}
-
-impl std::error::Error for YtDlpError {}
-
-impl Display for YtDlpError {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- YtDlpError::ResponseParseError { error } => write!(
- f,
- include_str!("./python_json_decode_failed.error_msg"),
- error
- ),
- YtDlpError::PythonError { error, kind: _ } => write!(f, "Python error: {error}"),
- YtDlpError::IoError { error } => write!(f, "Io error: {error}"),
- }
- }
-}
-
-impl From<serde_json::error::Error> for YtDlpError {
- fn from(value: serde_json::error::Error) -> Self {
- Self::ResponseParseError { error: value }
- }
-}
-
-impl From<pyo3::PyErr> for YtDlpError {
- fn from(value: pyo3::PyErr) -> Self {
- Python::with_gil(|py| {
- let kind = value.get_type(py).to_string();
- Self::PythonError {
- error: Box::new(value),
- kind,
- }
- })
- }
-}
-
-impl From<io::Error> for YtDlpError {
- fn from(value: io::Error) -> Self {
- Self::IoError { error: value }
- }
-}