pub struct ProducerContext { /* private fields */ }Expand description
Context provided to producers for dependency injection.
ProducerContext holds references to shared infrastructure components
that producers may need access to during message production.
Extensible via default_headers (headers injected into every outgoing
message) and timeout_ms (per-producer timeout override).
Implementations§
Source§impl ProducerContext
impl ProducerContext
Sourcepub fn new() -> ProducerContext
pub fn new() -> ProducerContext
Creates a new empty ProducerContext.
Sourcepub fn with_runtime(self, runtime: Arc<dyn RuntimeHandle>) -> ProducerContext
pub fn with_runtime(self, runtime: Arc<dyn RuntimeHandle>) -> ProducerContext
Attaches a runtime command/query handle.
Sourcepub fn runtime(&self) -> Option<&Arc<dyn RuntimeHandle>>
pub fn runtime(&self) -> Option<&Arc<dyn RuntimeHandle>>
Returns the runtime command/query handle, if configured.
Sourcepub fn with_default_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ProducerContext
pub fn with_default_header( self, key: impl Into<String>, value: impl Into<String>, ) -> ProducerContext
Sets a default header that will be injected into every outgoing message.
Sourcepub fn default_headers(&self) -> &HashMap<String, String>
pub fn default_headers(&self) -> &HashMap<String, String>
Returns the default headers map.
Sourcepub fn with_timeout_ms(self, timeout_ms: u64) -> ProducerContext
pub fn with_timeout_ms(self, timeout_ms: u64) -> ProducerContext
Sets a timeout in milliseconds for producer operations.
Sourcepub fn timeout_ms(&self) -> Option<u64>
pub fn timeout_ms(&self) -> Option<u64>
Returns the configured timeout in milliseconds, if any.
Trait Implementations§
Source§impl Clone for ProducerContext
impl Clone for ProducerContext
Source§fn clone(&self) -> ProducerContext
fn clone(&self) -> ProducerContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for ProducerContext
impl Default for ProducerContext
Source§fn default() -> ProducerContext
fn default() -> ProducerContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for ProducerContext
impl !UnwindSafe for ProducerContext
impl Freeze for ProducerContext
impl Send for ProducerContext
impl Sync for ProducerContext
impl Unpin for ProducerContext
impl UnsafeUnpin for ProducerContext
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