Struct Chain

Source
pub struct Chain<'c, S: Socket, ReplyParams, ReplyError> { /* private fields */ }
Expand description

A chain of method calls that will be sent together.

Each call must have the same method, reply, and error types for homogeneity. Use Connection::chain_call to create a new chain, extend it with Chain::append and send the the entire chain using Chain::send.

With std feature enabled, this supports unlimited calls. Otherwise it is limited by how many calls can fit in our fixed-sized buffer.

Oneway calls (where Call::oneway() == Some(true)) do not expect replies and are handled automatically by the chain.

Implementations§

Source§

impl<'c, S, ReplyParams, ReplyError> Chain<'c, S, ReplyParams, ReplyError>
where S: Socket, ReplyParams: Deserialize<'c> + Debug, ReplyError: Deserialize<'c> + Debug,

Source

pub fn append<Method>(self, call: &Call<Method>) -> Result<Self>
where Method: Serialize + Debug,

Append another method call to the chain.

The call will be enqueued but not sent until Chain::send is called. Note that one way calls (where Call::oneway() == Some(true)) do not receive replies.

Calls with more == Some(true) will stream multiple replies until a reply with continues != Some(true) is received.

Source

pub async fn send( self, ) -> Result<impl Stream<Item = Result<Result<ReplyParams, ReplyError>>> + 'c>
where ReplyParams: 'c, ReplyError: 'c,

Send all enqueued calls and return a replies stream.

This will flush all enqueued calls in a single write operation and then return a stream that allows reading the replies.

Trait Implementations§

Source§

impl<'c, S: Debug + Socket, ReplyParams: Debug, ReplyError: Debug> Debug for Chain<'c, S, ReplyParams, ReplyError>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c, S, ReplyParams, ReplyError> Freeze for Chain<'c, S, ReplyParams, ReplyError>

§

impl<'c, S, ReplyParams, ReplyError> RefUnwindSafe for Chain<'c, S, ReplyParams, ReplyError>
where ReplyParams: RefUnwindSafe, ReplyError: RefUnwindSafe, <S as Socket>::ReadHalf: RefUnwindSafe, <S as Socket>::WriteHalf: RefUnwindSafe,

§

impl<'c, S, ReplyParams, ReplyError> Send for Chain<'c, S, ReplyParams, ReplyError>
where ReplyParams: Send, ReplyError: Send, <S as Socket>::ReadHalf: Send, <S as Socket>::WriteHalf: Send,

§

impl<'c, S, ReplyParams, ReplyError> Sync for Chain<'c, S, ReplyParams, ReplyError>
where ReplyParams: Sync, ReplyError: Sync, <S as Socket>::ReadHalf: Sync, <S as Socket>::WriteHalf: Sync,

§

impl<'c, S, ReplyParams, ReplyError> Unpin for Chain<'c, S, ReplyParams, ReplyError>
where ReplyParams: Unpin, ReplyError: Unpin,

§

impl<'c, S, ReplyParams, ReplyError> !UnwindSafe for Chain<'c, S, ReplyParams, ReplyError>

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<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