Skip to main content

ContextExt

Trait ContextExt 

Source
pub trait ContextExt<T> {
    // Required methods
    fn with_protocol_context(
        self,
        protocol: &'static str,
        role: &'static str,
        phase: &'static str,
    ) -> ChoreoResult<T>;
    fn with_role_context(
        self,
        role: &'static str,
        index: Option<u32>,
    ) -> ChoreoResult<T>;
    fn with_message_context(
        self,
        operation: &'static str,
        message_type: &'static str,
        direction: &'static str,
        other_role: &'static str,
    ) -> ChoreoResult<T>;
    fn with_context(self, context: impl Into<String>) -> ChoreoResult<T>;
}
Expand description

Extension trait for adding context to Results.

This trait provides ergonomic methods for wrapping errors with protocol/role/phase context.

Required Methods§

Source

fn with_protocol_context( self, protocol: &'static str, role: &'static str, phase: &'static str, ) -> ChoreoResult<T>

Add protocol context to an error.

Source

fn with_role_context( self, role: &'static str, index: Option<u32>, ) -> ChoreoResult<T>

Add role context to an error.

Source

fn with_message_context( self, operation: &'static str, message_type: &'static str, direction: &'static str, other_role: &'static str, ) -> ChoreoResult<T>

Add message context to an error.

Source

fn with_context(self, context: impl Into<String>) -> ChoreoResult<T>

Add generic context to an error.

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.

Implementors§