mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-15 14:52:04 +00:00
uriplaylistbin: use thiserror
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1234>
This commit is contained in:
parent
e33543dbfa
commit
3a98bacd39
2 changed files with 4 additions and 24 deletions
|
@ -13,6 +13,7 @@ gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/g
|
||||||
once_cell = "1.0"
|
once_cell = "1.0"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
clap = { version = "4", optional = true, features = ["derive"] }
|
clap = { version = "4", optional = true, features = ["derive"] }
|
||||||
|
thiserror = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", branch = "0.19", version = "0.19" }
|
gst-app = { package = "gstreamer-app", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", branch = "0.19", version = "0.19" }
|
||||||
|
|
|
@ -26,35 +26,14 @@ static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
/// how many items are allowed to be prepared and waiting in the pipeline
|
/// how many items are allowed to be prepared and waiting in the pipeline
|
||||||
const MAX_STREAMING_ITEMS: usize = 2;
|
const MAX_STREAMING_ITEMS: usize = 2;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
enum PlaylistError {
|
enum PlaylistError {
|
||||||
|
#[error("plugin missing: {error}")]
|
||||||
PluginMissing { error: anyhow::Error },
|
PluginMissing { error: anyhow::Error },
|
||||||
|
#[error("{item:?} failed: {error}")]
|
||||||
ItemFailed { error: anyhow::Error, item: Item },
|
ItemFailed { error: anyhow::Error, item: Item },
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for PlaylistError {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
PlaylistError::PluginMissing { error } => {
|
|
||||||
write!(f, "{}", error)
|
|
||||||
}
|
|
||||||
PlaylistError::ItemFailed { error, item } => {
|
|
||||||
write!(f, "{} (URI: {})", error, item.uri())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::error::Error for PlaylistError {
|
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
|
|
||||||
match self {
|
|
||||||
PlaylistError::PluginMissing { error } | PlaylistError::ItemFailed { error, .. } => {
|
|
||||||
Some(error.as_ref())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Number of different streams currently handled by the element
|
/// Number of different streams currently handled by the element
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq)]
|
||||||
struct StreamsTopology {
|
struct StreamsTopology {
|
||||||
|
|
Loading…
Reference in a new issue