INNER CODE UNIT · Rust
try_from
trussed-dev/trussed · src/backend.rs:93
fn try_from(_: u8) -> Result<Self, Self::Error> {
Err(Error::InternalError)
}
}
/// Helper type for optional backends.
///
/// If the backend is `None`, [`Error::RequestNotAvailable`][] is returned.
#[derive(Debug)]
pub struct OptionalBackend<T>(Option<T>);
impl<T> OptionalBackend<T> {
/// Crates a new optional backend from an `Option<T>`.
pub fn new(backend: Option<T>) -> Self {
Self(backend)
}
/// Returns a mutable reference to the wrapped backend or [`Error::RequestNotAvailable`][] if