pub struct Outgoing<'a> { /* private fields */ }Expand description
A mutable outgoing message flowing through the publish pipeline.
The name is an OutgoingName, which carries a destination from any of the
three places one comes from without copying it: the macro reply path borrows a string literal
(reply_name(&self) -> &str), a computed name moves in owned, and a name read off the
delivery being answered arrives as the delivery’s own buffer. The payload behaves the same
way: codec output moves in whole, a rebuilt message carries the buffer it was handed or lends
the bytes it was lent, and the first payload_mut or
set_payload is what makes the buffer this message’s own. Middleware may
change the name, transform the payload, and enrich the headers before
the message is sent.
Implementations§
Source§impl<'a> Outgoing<'a>
impl<'a> Outgoing<'a>
Sourcepub fn set_name(&mut self, name: impl Into<OutgoingName<'a>>)
pub fn set_name(&mut self, name: impl Into<OutgoingName<'a>>)
Sets the destination name.
A literal or a borrow costs nothing, a computed String moves in, and a Str read off
the delivery shares its buffer rather than copying out of it.
§Examples
use ruststream::{Bytes, Str};
use ruststream::runtime::Outgoing;
let mut out = Outgoing::new("answers", b"{}".as_slice());
out.set_name("replies.inbox");
assert_eq!(out.name(), "replies.inbox");
// The same setter takes the buffer a delivery arrived in, with no copy between them.
out.set_name(Str::try_from(Bytes::from_static(b"replies.7"))?);
assert_eq!(out.name(), "replies.7");Sourcepub fn payload_mut(&mut self) -> &mut BytesMut
pub fn payload_mut(&mut self) -> &mut BytesMut
The payload bytes, mutably (for envelope wrapping).
A message that is still lending the bytes it was built from copies them here, once.
Sourcepub fn set_payload(&mut self, payload: impl Into<BytesMut>)
pub fn set_payload(&mut self, payload: impl Into<BytesMut>)
Replaces the payload.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
The outgoing headers, mutably.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !Freeze for Outgoing<'a>
impl<'a> RefUnwindSafe for Outgoing<'a>
impl<'a> Send for Outgoing<'a>
impl<'a> Sync for Outgoing<'a>
impl<'a> Unpin for Outgoing<'a>
impl<'a> UnsafeUnpin for Outgoing<'a>
impl<'a> UnwindSafe for Outgoing<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
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> ⓘ
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>
T in a tonic::Request