pub struct BusHandle { /* private fields */ }Expand description
A scoped handle that a single agent uses to send and receive messages.
The handle knows the agent’s id and uses it as sender_id on outgoing
envelopes. It also provides filtered receive helpers.
Implementations§
Source§impl BusHandle
impl BusHandle
Sourcepub fn send(&self, topic: impl Into<String>, message: BusMessage) -> usize
pub fn send(&self, topic: impl Into<String>, message: BusMessage) -> usize
Send a message on the given topic.
Sourcepub fn send_with_correlation(
&self,
topic: impl Into<String>,
message: BusMessage,
correlation_id: Option<String>,
) -> usize
pub fn send_with_correlation( &self, topic: impl Into<String>, message: BusMessage, correlation_id: Option<String>, ) -> usize
Send a message with a correlation id.
Sourcepub fn announce_ready(&self, capabilities: Vec<String>) -> usize
pub fn announce_ready(&self, capabilities: Vec<String>) -> usize
Announce this agent as ready.
Sourcepub fn announce_shutdown(&self) -> usize
pub fn announce_shutdown(&self) -> usize
Announce this agent is shutting down.
Sourcepub fn send_task_update(
&self,
task_id: &str,
state: TaskState,
message: Option<String>,
) -> usize
pub fn send_task_update( &self, task_id: &str, state: TaskState, message: Option<String>, ) -> usize
Announce a task status update.
Sourcepub fn send_artifact_update(&self, task_id: &str, artifact: Artifact) -> usize
pub fn send_artifact_update(&self, task_id: &str, artifact: Artifact) -> usize
Announce an artifact update.
Sourcepub fn send_to_agent(&self, to: &str, parts: Vec<Part>) -> usize
pub fn send_to_agent(&self, to: &str, parts: Vec<Part>) -> usize
Send a direct message to another agent.
Publish a shared result (visible to the entire swarm).
Sourcepub async fn recv(&mut self) -> Option<BusEnvelope>
pub async fn recv(&mut self) -> Option<BusEnvelope>
Receive the next envelope (blocks until available).
Sourcepub async fn recv_topic(&mut self, prefix: &str) -> Option<BusEnvelope>
pub async fn recv_topic(&mut self, prefix: &str) -> Option<BusEnvelope>
Receive the next envelope whose topic starts with the given prefix.
Sourcepub async fn recv_mine(&mut self) -> Option<BusEnvelope>
pub async fn recv_mine(&mut self) -> Option<BusEnvelope>
Receive the next envelope addressed to this agent.
Sourcepub fn try_recv(&mut self) -> Option<BusEnvelope>
pub fn try_recv(&mut self) -> Option<BusEnvelope>
Try to receive without blocking. Returns None if no message is
queued.
Sourcepub fn registry(&self) -> &Arc<AgentRegistry>
pub fn registry(&self) -> &Arc<AgentRegistry>
Access the agent registry.
Auto Trait Implementations§
impl Freeze for BusHandle
impl !RefUnwindSafe for BusHandle
impl Send for BusHandle
impl Sync for BusHandle
impl Unpin for BusHandle
impl !UnwindSafe for BusHandle
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ServiceExt for T
impl<T> ServiceExt for T
Source§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
Source§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
Source§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more