DispatchBuilder

Struct DispatchBuilder 

Source
pub struct DispatchBuilder { /* private fields */ }
Expand description

Allows building an outgoing RabbitMQ Dispatch iteratively.

Expects that the payload has been converted to a vector of bytes.

Implementations§

Source§

impl DispatchBuilder

Source

pub fn new() -> Self

Creates a new Dispatch builder.

Source

pub fn with_bytes(self, bytes: Vec<u8>) -> Self

Sets the payload of this Dispatch to the given bytes.

This method is specifically made to take an owned Vec<u8>, to make sure no copying occurs and the bytes are simply moved into this dispatch.

When copying of bytes is acceptable or desired, use with_byte_ref.

Source

pub fn with_byte_ref(self, bytes: impl AsRef<[u8]>) -> Self

Copies the given bytes to the payload of this Dispatch.

Source

pub fn durable(self) -> Self

Sets the durability flag in the AMQPProperties of this Dispatch to “durable”.

Source

pub fn transient(self) -> Self

Sets the durability flag in the AMQPProperties of this Dispatch to “transient”.

Source

pub fn with_priority(self, priority: u8) -> Self

Sets the priority in the AMQPProperties of this Dispatch to the given value.

Source

pub fn with_timestamp(self, timestamp: u64) -> Self

Sets the timestamp in the AMQPProperties of this Dispatch to the given value.

Source

pub fn with_current_timestamp(self) -> Self

Sets the timestamp in the AMQPProperties of this Dispatch to the current timestamp.

Source

pub fn with_attempt(self, attempt: u32) -> Self

Sets the attempt header of this Dispatch to the given value.

Source

pub fn with_incremented_attempt(self) -> Self

Increments the attempt header of this Dispatch by one. If the attempt is not yet present, it will be assumed to be zero, and will be incremented to one.

Source

pub fn with_content_type<T>(self, content_type: T) -> Self
where ShortString: Morph<T>,

Sets the content type of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_content_type("application/json").build();
Source

pub fn with_content_encoding<T>(self, content_encoding: T) -> Self
where ShortString: Morph<T>,

Sets the content encoding of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_content_encoding("gzip").build();
Source

pub fn with_header<T>(self, key: &str, value: T) -> Self
where AMQPValue: Morph<T>,

Sets a header of this Dispatch under the given key to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder()
    .with_header("created_via", "strut")
    .with_header("processed_in_secs", 12.9)
    .build();
Source

pub fn with_correlation_id<T>(self, correlation_id: T) -> Self
where ShortString: Morph<T>,

Sets the correlation ID of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_correlation_id(4489).build();
Source

pub fn with_reply_to<T>(self, reply_to: T) -> Self
where ShortString: Morph<T>,

Sets the “reply-to” value of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_reply_to("me").build();
Source

pub fn with_expiration<T>(self, expiration: T) -> Self
where ShortString: Morph<T>,

Sets the expiration of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_expiration(86400).build();
Source

pub fn with_message_id<T>(self, message_id: T) -> Self
where ShortString: Morph<T>,

Sets the message ID of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_message_id(664833405).build();
Source

pub fn with_kind<T>(self, kind: T) -> Self
where ShortString: Morph<T>,

Sets the kind of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_kind("priority").build();
Source

pub fn with_user_id<T>(self, user_id: T) -> Self
where ShortString: Morph<T>,

Sets the user ID of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder()
    .with_user_id("01522090-f465-4a44-bd3d-9e06c061f6ac")
    .build();
Source

pub fn with_app_id<T>(self, app_id: T) -> Self
where ShortString: Morph<T>,

Sets the app ID of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_app_id("app_17").build();
Source

pub fn with_cluster_id<T>(self, cluster_id: T) -> Self
where ShortString: Morph<T>,

Sets the cluster ID of this Dispatch to the given value.

§Example
use strut_rabbitmq::Dispatch;

let dispatch = Dispatch::builder().with_cluster_id(7747).build();
Source

pub fn with_routing_key(self, routing_key: impl Into<String>) -> Self

Defines a routing key to be used just for this dispatch.

If this method is never called, the Publisher instead uses the routing key configured on the Egress.

Source

pub fn build(self) -> Dispatch

Builds the Dispatch.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,