wlan_fidl_ext/
send_result_ext.rsuse anyhow::format_err;
use std::fmt::Display;
pub trait SendResultExt<T>: Sized {
fn format_send_err(self) -> Result<T, anyhow::Error>;
fn format_send_err_with_context<C>(self, context: C) -> Result<T, anyhow::Error>
where
C: Display;
}
impl<T> SendResultExt<T> for Result<T, fidl::Error> {
fn format_send_err(self) -> Result<T, anyhow::Error> {
self.map_err(|error| format_err!("Failed to respond: {}", error))
}
fn format_send_err_with_context<C>(self, context: C) -> Result<T, anyhow::Error>
where
C: Display,
{
self.map_err(|error| format_err!("Failed to respond ({}): {}", context, error))
}
}