pub enum BidirError {
NotSupported,
Timeout(u64),
Cancelled,
TypeMismatch {
expected: String,
got: String,
},
Serialization(String),
Transport(String),
UnknownRequest,
ChannelClosed,
}Expand description
Error types for bidirectional communication
This enum covers all failure modes that can occur during bidirectional
request/response cycles. Activations should handle these errors gracefully,
especially BidirError::NotSupported which indicates the transport
cannot support interactive features.
§Common Patterns
use plexus_core::plexus::bidirectional::{BidirError, StandardBidirChannel};
async fn my_method(ctx: &StandardBidirChannel) {
match ctx.confirm("Proceed?").await {
Ok(true) => { /* user confirmed */ }
Ok(false) => { /* user declined */ }
Err(BidirError::NotSupported) => {
// Non-interactive transport - use safe defaults
}
Err(BidirError::Cancelled) => {
// User explicitly cancelled
}
Err(BidirError::Timeout(_)) => {
// User didn't respond in time
}
Err(e) => {
// Other errors - log and handle
eprintln!("Bidirectional error: {}", e);
}
}
}Variants§
NotSupported
Transport does not support bidirectional communication.
This is a normal condition - many transports (HTTP, some MCP configs) cannot support server-to-client requests. Activations should have fallback behavior when this error occurs.
§Example
match ctx.confirm("Delete?").await {
Err(BidirError::NotSupported) => {
// Don't delete without confirmation
return Err("Interactive confirmation required");
}
// ...
}Timeout(u64)
Request timed out waiting for client response.
The timeout value (in milliseconds) is included. Default timeout
is 30 seconds, configurable via request_with_timeout() method.
§Example
match ctx.confirm("Confirm?").await {
Err(BidirError::Timeout(ms)) => {
println!("No response after {}ms", ms);
}
// ...
}Cancelled
Client explicitly cancelled the request.
This indicates the user chose to cancel rather than respond. Different from declining - cancel means “abort the workflow”.
TypeMismatch
Response type doesn’t match expected type.
This usually indicates a bug in client code or a protocol mismatch.
For example, responding with Text to a Confirm request.
Serialization(String)
Failed to serialize or deserialize request/response.
Contains the underlying serialization error message.
Transport(String)
Transport-level error during communication.
This covers network errors, connection drops, etc.
UnknownRequest
Unknown request ID (response for non-existent request).
This can happen if:
- The request already timed out
- The request was cancelled
- The request ID was corrupted
ChannelClosed
Response channel was closed before response received.
This typically means the waiting task was cancelled or dropped.
Trait Implementations§
Source§impl Clone for BidirError
impl Clone for BidirError
Source§fn clone(&self) -> BidirError
fn clone(&self) -> BidirError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for BidirError
impl Debug for BidirError
Source§impl Display for BidirError
impl Display for BidirError
Source§impl Error for BidirError
impl Error for BidirError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl Freeze for BidirError
impl RefUnwindSafe for BidirError
impl Send for BidirError
impl Sync for BidirError
impl Unpin for BidirError
impl UnsafeUnpin for BidirError
impl UnwindSafe for BidirError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.