pub struct NatsTransport { /* private fields */ }Expand description
Owns a NATS connection and transport configuration.
Implementations§
Source§impl NatsTransport
impl NatsTransport
pub fn new(client: Client, config: NatsTransportConfig) -> Self
pub fn client(&self) -> &Client
Sourcepub async fn serve<H, Fut>(
&self,
subject: &str,
protocol_label: &'static str,
handler: H,
) -> Result<(), NatsProtocolError>where
H: Fn(NatsTransport, Message) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), NatsProtocolError>> + Send + 'static,
pub async fn serve<H, Fut>(
&self,
subject: &str,
protocol_label: &'static str,
handler: H,
) -> Result<(), NatsProtocolError>where
H: Fn(NatsTransport, Message) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), NatsProtocolError>> + Send + 'static,
Subscribe to a NATS subject and dispatch each message to a handler.
pub async fn publish_run_stream<E, BuildEncoder>(
&self,
run: RunStream,
reply: Subject,
build_encoder: BuildEncoder,
) -> Result<(), NatsProtocolError>where
E: Transcoder<Input = AgentEvent> + 'static,
E::Output: Serialize + Send + 'static,
BuildEncoder: FnOnce(&RunStream) -> E,
Trait Implementations§
Source§impl Clone for NatsTransport
impl Clone for NatsTransport
Source§fn clone(&self) -> NatsTransport
fn clone(&self) -> NatsTransport
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for NatsTransport
impl !RefUnwindSafe for NatsTransport
impl Send for NatsTransport
impl Sync for NatsTransport
impl Unpin for NatsTransport
impl !UnwindSafe for NatsTransport
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