pub struct BusClient { /* private fields */ }Expand description
Low-level TCP service-bus client.
Implementations§
Source§impl BusClient
impl BusClient
Sourcepub async fn connect(
host: &str,
port: u16,
service_id: impl Into<String>,
instance_id: impl Into<String>,
token: impl Into<String>,
) -> ClientResult<Self>
pub async fn connect( host: &str, port: u16, service_id: impl Into<String>, instance_id: impl Into<String>, token: impl Into<String>, ) -> ClientResult<Self>
Opens a TCP connection and authenticates with a connect protocol frame.
Sourcepub async fn subscribe(&self, topics: Vec<String>) -> ClientResult<()>
pub async fn subscribe(&self, topics: Vec<String>) -> ClientResult<()>
Subscribes to one or more topics and waits for an ack.
Sourcepub async fn unsubscribe(&self, topics: Vec<String>) -> ClientResult<()>
pub async fn unsubscribe(&self, topics: Vec<String>) -> ClientResult<()>
Unsubscribes from topics without waiting for a response frame.
Sourcepub async fn publish(
&self,
topic: impl Into<String>,
message_type: impl Into<String>,
payload: HashMap<String, Value>,
) -> ClientResult<i32>
pub async fn publish( &self, topic: impl Into<String>, message_type: impl Into<String>, payload: HashMap<String, Value>, ) -> ClientResult<i32>
Publishes a topic + message-type payload and returns subscriber count.
Sourcepub async fn publish_event(
&self,
event: ServiceBusEventEnvelope,
) -> ClientResult<i32>
pub async fn publish_event( &self, event: ServiceBusEventEnvelope, ) -> ClientResult<i32>
Publishes a fully formed event envelope and returns the subscriber count.
Sourcepub async fn forward(
&self,
request: ForwardRequest,
) -> ClientResult<ServiceBusForwardResponse>
pub async fn forward( &self, request: ForwardRequest, ) -> ClientResult<ServiceBusForwardResponse>
Sends a forward request and validates a forward_response frame.
Sourcepub async fn on_event<F, Fut>(
&self,
topic: impl Into<String>,
handler: F,
) -> ClientResult<()>
pub async fn on_event<F, Fut>( &self, topic: impl Into<String>, handler: F, ) -> ClientResult<()>
Registers an async event handler for a topic and subscribes automatically.
Sourcepub async fn on_request<F, Fut>(
&self,
topic: impl Into<String>,
responder: F,
) -> ClientResult<()>where
F: Fn(ServiceBusRequest, RequestResponder) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ClientResult<()>> + Send + 'static,
pub async fn on_request<F, Fut>(
&self,
topic: impl Into<String>,
responder: F,
) -> ClientResult<()>where
F: Fn(ServiceBusRequest, RequestResponder) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ClientResult<()>> + Send + 'static,
Registers an async request responder by message type.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BusClient
impl !UnwindSafe for BusClient
impl Freeze for BusClient
impl Send for BusClient
impl Sync for BusClient
impl Unpin for BusClient
impl UnsafeUnpin for BusClient
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