pub fn with_device<F, T, E>(
device: Option<Rc<RefCell<TpmDevice>>>,
f: F,
) -> Result<T, E>Expand description
Executes a closure with a mutable reference to a TpmDevice.
This helper function centralizes the boilerplate for safely acquiring a
mutable borrow of a TpmDevice from the shared Rc<RefCell<...>>.
§Errors
Returns NotAvailable when no device
is present and AlreadyBorrowed
when the device is already mutably borrowed, both converted into the caller’s
error type E. Propagates any error returned by the closure f.