pub struct MessageBus { /* private fields */ }Implementations§
Source§impl MessageBus
impl MessageBus
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new message bus with a custom channel capacity.
Higher capacity allows more burst buffering at the cost of memory. Lower capacity provides tighter backpressure.
Sourcepub fn publish_inbound(&self, msg: InboundMessage) -> Result<(), ClawftError>
pub fn publish_inbound(&self, msg: InboundMessage) -> Result<(), ClawftError>
Publish an inbound message (from a channel adapter) to the bus.
Uses try_send to avoid requiring the caller to be async.
Returns an error if the channel is closed or the buffer is full.
Sourcepub async fn publish_inbound_async(
&self,
msg: InboundMessage,
) -> Result<(), ClawftError>
pub async fn publish_inbound_async( &self, msg: InboundMessage, ) -> Result<(), ClawftError>
Publish an inbound message, waiting asynchronously if the buffer is full.
Prefer this over publish_inbound in async
contexts to avoid dropping messages under backpressure.
Sourcepub async fn consume_inbound(&self) -> Option<InboundMessage>
pub async fn consume_inbound(&self) -> Option<InboundMessage>
Consume the next inbound message from the bus.
Returns None if the channel is closed and all buffered messages
have been consumed.
Sourcepub fn dispatch_outbound(&self, msg: OutboundMessage) -> Result<(), ClawftError>
pub fn dispatch_outbound(&self, msg: OutboundMessage) -> Result<(), ClawftError>
Dispatch an outbound message (from the agent pipeline) to the bus.
Uses try_send to avoid requiring the caller to be async.
Returns an error if the channel is closed or the buffer is full.
Sourcepub async fn dispatch_outbound_async(
&self,
msg: OutboundMessage,
) -> Result<(), ClawftError>
pub async fn dispatch_outbound_async( &self, msg: OutboundMessage, ) -> Result<(), ClawftError>
Dispatch an outbound message, waiting asynchronously if the buffer is full.
Sourcepub async fn consume_outbound(&self) -> Option<OutboundMessage>
pub async fn consume_outbound(&self) -> Option<OutboundMessage>
Consume the next outbound message from the bus.
Returns None if the channel is closed and all buffered messages
have been consumed.
Sourcepub fn inbound_sender(&self) -> Sender<InboundMessage>
pub fn inbound_sender(&self) -> Sender<InboundMessage>
Get a cloneable sender handle for publishing inbound messages.
Channel adapters should clone this sender so that multiple producers (e.g. Telegram, Slack, Discord) can publish concurrently.
Sourcepub fn outbound_sender(&self) -> Sender<OutboundMessage>
pub fn outbound_sender(&self) -> Sender<OutboundMessage>
Get a cloneable sender handle for dispatching outbound messages.
Pipeline stages or agent tasks can clone this sender for concurrent outbound dispatch.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MessageBus
impl !RefUnwindSafe for MessageBus
impl Send for MessageBus
impl Sync for MessageBus
impl Unpin for MessageBus
impl UnsafeUnpin for MessageBus
impl !UnwindSafe for MessageBus
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> 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 more