Skip to main content

oximedia_plugin/
error.rs

1//! Plugin-specific error types.
2
3use thiserror::Error;
4
5/// Errors that can occur during plugin operations.
6#[derive(Error, Debug)]
7pub enum PluginError {
8    /// The requested plugin was not found in the registry.
9    #[error("Plugin not found: {0}")]
10    NotFound(String),
11
12    /// Failed to load a plugin from a shared library.
13    #[error("Plugin load failed: {0}")]
14    LoadFailed(String),
15
16    /// Plugin API version does not match the host.
17    #[error("Plugin version mismatch: expected {expected}, got {actual}")]
18    VersionMismatch {
19        /// The expected version string.
20        expected: String,
21        /// The actual version string found.
22        actual: String,
23    },
24
25    /// Plugin initialization failed after loading.
26    #[error("Plugin initialization failed: {0}")]
27    InitFailed(String),
28
29    /// The requested codec is not provided by any loaded plugin.
30    #[error("Codec not provided by plugin: {0}")]
31    CodecNotAvailable(String),
32
33    /// The plugin's API version is incompatible with the host.
34    #[error("Plugin API version incompatible: {0}")]
35    ApiIncompatible(String),
36
37    /// Dynamic loading was requested but the feature is not enabled.
38    #[error("Dynamic loading not enabled (compile with 'dynamic-loading' feature)")]
39    DynamicLoadingDisabled,
40
41    /// An I/O error occurred during plugin operations.
42    #[error("I/O error: {0}")]
43    Io(#[from] std::io::Error),
44
45    /// A codec-level error propagated from the plugin.
46    #[error("Codec error: {0}")]
47    Codec(#[from] oximedia_codec::CodecError),
48
49    /// The plugin manifest file is invalid or malformed.
50    #[error("Invalid manifest: {0}")]
51    InvalidManifest(String),
52
53    /// A plugin with the same name is already registered.
54    #[error("Plugin already registered: {0}")]
55    AlreadyRegistered(String),
56
57    /// JSON serialization/deserialization error.
58    #[error("JSON error: {0}")]
59    Json(#[from] serde_json::Error),
60}
61
62/// Result type alias for plugin operations.
63pub type PluginResult<T> = Result<T, PluginError>;