Skip to main content

WithChannels

Struct WithChannels 

Source
pub struct WithChannels<I: Channels<S>, S: Service> {
    pub inner: I,
    pub tx: <I as Channels<S>>::Tx,
    pub rx: <I as Channels<S>>::Rx,
    pub span: Span,
}
Expand description

A wrapper for a message with channels to send and receive it. This expands the protocol message to a full message that includes the active and unserializable channels.

The channel kind for rx and tx is defined by implementing the Channels trait, either manually or using a macro.

When the spans feature is enabled, this also includes a tracing span to carry the tracing context during message passing.

Fields§

§inner: I

The inner message.

§tx: <I as Channels<S>>::Tx

The return channel to send the response to. Can be set to crate::channel::none::NoSender if not needed.

§rx: <I as Channels<S>>::Rx

The request channel to receive the request from. Can be set to NoReceiver if not needed.

§span: Span
Available on crate feature spans only.

The current span where the full message was created.

Implementations§

Source§

impl<I: Channels<S>, S: Service> WithChannels<I, S>

Source

pub fn parent_span_opt(&self) -> Option<&Span>

Available on crate feature spans only.

Get the parent span

Trait Implementations§

Source§

impl<I: Channels<S> + Debug, S: Service> Debug for WithChannels<I, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I: Channels<S>, S: Service> Deref for WithChannels<I, S>

Deref so you can access the inner fields directly.

If the inner message has fields named tx, rx or span, you need to use the inner field to access them.

Source§

type Target = I

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<I, S> From<(I,)> for WithChannels<I, S>
where I: Channels<S, Rx = NoReceiver, Tx = NoSender>, S: Service,

Tuple conversion from inner message to a WithChannels struct without channels

Source§

fn from(inner: (I,)) -> Self

Converts to this type from the input type.
Source§

impl<I, S, Tx> From<(I, Tx)> for WithChannels<I, S>
where I: Channels<S, Rx = NoReceiver>, S: Service, <I as Channels<S>>::Tx: From<Tx>,

Tuple conversion from inner message and tx channel to a WithChannels struct

For the very common case where you just need a tx channel to send the response to.

Source§

fn from(inner: (I, Tx)) -> Self

Converts to this type from the input type.
Source§

impl<I, S: Service, Tx, Rx> From<(I, Tx, Rx)> for WithChannels<I, S>
where I: Channels<S>, <I as Channels<S>>::Tx: From<Tx>, <I as Channels<S>>::Rx: From<Rx>,

Tuple conversion from inner message and tx/rx channels to a WithChannels struct

For the case where you want both tx and rx channels.

Source§

fn from(inner: (I, Tx, Rx)) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<I, S> Freeze for WithChannels<I, S>
where I: Freeze, <I as Channels<S>>::Tx: Freeze, <I as Channels<S>>::Rx: Freeze,

§

impl<I, S> !RefUnwindSafe for WithChannels<I, S>

§

impl<I, S> Send for WithChannels<I, S>
where <I as Channels<S>>::Tx: Send, <I as Channels<S>>::Rx: Send,

§

impl<I, S> Sync for WithChannels<I, S>
where I: Sync, <I as Channels<S>>::Tx: Sync, <I as Channels<S>>::Rx: Sync,

§

impl<I, S> Unpin for WithChannels<I, S>
where I: Unpin, <I as Channels<S>>::Tx: Unpin, <I as Channels<S>>::Rx: Unpin,

§

impl<I, S> UnsafeUnpin for WithChannels<I, S>
where I: UnsafeUnpin, <I as Channels<S>>::Tx: UnsafeUnpin, <I as Channels<S>>::Rx: UnsafeUnpin,

§

impl<I, S> !UnwindSafe for WithChannels<I, S>

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<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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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<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