pub trait GuestErrorContext {
type Ok;
// Required methods
fn context(self, ctx: impl Into<String>) -> Result<Self::Ok>;
fn context_and_code(
self,
ec: ErrorCode,
ctx: impl Into<String>,
) -> Result<Self::Ok>;
fn with_context<S: Into<String>>(
self,
ctx: impl FnOnce() -> S,
) -> Result<Self::Ok>;
fn with_context_and_code<S: Into<String>>(
self,
ec: ErrorCode,
ctx: impl FnOnce() -> S,
) -> Result<Self::Ok>;
}Expand description
Extension trait to add context to Option<T> and Result<T, E> types in guest code,
converting them to Result<T, HyperlightGuestError>.
This is similar to anyhow::Context.
Required Associated Types§
Required Methods§
Sourcefn context(self, ctx: impl Into<String>) -> Result<Self::Ok>
fn context(self, ctx: impl Into<String>) -> Result<Self::Ok>
Adds context to the error if self is None or Err.
Sourcefn context_and_code(
self,
ec: ErrorCode,
ctx: impl Into<String>,
) -> Result<Self::Ok>
fn context_and_code( self, ec: ErrorCode, ctx: impl Into<String>, ) -> Result<Self::Ok>
Adds context and a specific error code to the error if self is None or Err.
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.