pub trait MapErrorToPyErr {
// Required methods
fn try_map<T: Error + 'static>(
py: Python<'_>,
err: Box<dyn Error + 'static>,
map: impl FnOnce(Box<T>) -> PyErr,
) -> Result<PyErr, Box<dyn Error + 'static>>;
fn try_map_send_sync<T: Error + 'static>(
py: Python<'_>,
err: Box<dyn Error + Send + Sync + 'static>,
map: impl FnOnce(Box<T>) -> PyErr,
) -> Result<PyErr, Box<dyn Error + Send + Sync + 'static>>;
fn try_map_ref<T: Error + 'static>(
py: Python<'_>,
err: &(dyn Error + 'static),
map: impl FnOnce(&T) -> PyErr,
) -> Option<PyErr>;
}
Expand description
Utility trait to try to translate via specific error types E
implementing
std::error::Error
and wrapped errors such as MyError<E>
to PyErr
s.
DowncastToPyErr
may be used to only try to translate via E
using
downcasting.
Required Methods§
Sourcefn try_map<T: Error + 'static>(
py: Python<'_>,
err: Box<dyn Error + 'static>,
map: impl FnOnce(Box<T>) -> PyErr,
) -> Result<PyErr, Box<dyn Error + 'static>>
fn try_map<T: Error + 'static>( py: Python<'_>, err: Box<dyn Error + 'static>, map: impl FnOnce(Box<T>) -> PyErr, ) -> Result<PyErr, Box<dyn Error + 'static>>
Sourcefn try_map_send_sync<T: Error + 'static>(
py: Python<'_>,
err: Box<dyn Error + Send + Sync + 'static>,
map: impl FnOnce(Box<T>) -> PyErr,
) -> Result<PyErr, Box<dyn Error + Send + Sync + 'static>>
fn try_map_send_sync<T: Error + 'static>( py: Python<'_>, err: Box<dyn Error + Send + Sync + 'static>, map: impl FnOnce(Box<T>) -> PyErr, ) -> Result<PyErr, Box<dyn Error + Send + Sync + 'static>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.