mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-05 22:47:02 -04:00
`matrix-sdk-crypto-nodejs` and `matrix-sdk-crypto-js` are no longer default members of the Cargo virtual workspace. The Github Actions workflows for the bindings now live in a `bindings_ci.yml` files (ideally, it should be in a subdirectory, `.github/workflows/bindings/ci.yml` but it doesn't work).
29 lines
550 B
Rust
29 lines
550 B
Rust
/// Generic error wrapping `napi::Error`.
|
|
#[derive(Debug)]
|
|
pub struct Error(napi::Error);
|
|
|
|
impl<E> From<E> for Error
|
|
where
|
|
E: std::error::Error,
|
|
{
|
|
fn from(error: E) -> Self {
|
|
Self(napi::Error::from_reason(error.to_string()))
|
|
}
|
|
}
|
|
|
|
impl From<Error> for napi::Error {
|
|
#[inline]
|
|
fn from(value: Error) -> Self {
|
|
value.0
|
|
}
|
|
}
|
|
|
|
/// Helper to replace the `E` to `Error` to `napi::Error` conversion.
|
|
#[inline]
|
|
pub fn into_err<E>(error: E) -> napi::Error
|
|
where
|
|
E: std::error::Error,
|
|
{
|
|
Error::from(error).into()
|
|
}
|