CallHandle

Struct CallHandle 

Source
pub struct CallHandle<'a> { /* private fields */ }
Expand description

A handle for waiting on the return values of remote procedure calls. This is necessary because calling a remote procedure requires .flush() to be called, so waiting inside a function like .call() would make very little sense.

Implementations§

Source§

impl<'a> CallHandle<'a>

Source

pub async fn wait<T: DeserializeOwned>(self) -> Result<T, Error>

Waits for the procedure call to complete and returns the result.

Termination behaviour: if the wire terminates during this call, the completion lock on the message this waits for will be explicitly poisoned, causing this call to fail with [Error::LockPoisoned].

Source

pub async fn wait_chunks<T: DeserializeOwned>( self, ) -> Result<Option<Vec<T>>, Error>

Same as .wait(), but this will use chunk-based deserialisation, and is intended for use with procedures that send sequences of discrete values gradually over the wire. For more information, see Interface::get_chunks.

Termination behaviour: if the wire terminates during this call, the completion lock on the message this waits for will be explicitly poisoned, causing this call to fail with [Error::LockPoisoned].

Source

pub async fn wait_chunk_stream(self) -> Result<ChunkReceiverHandle, Error>

Creates a [ChunkReceiverHandle] for incrementally receiving each chunk as it arrives. This can be used for accessing data in a semi-realtime way while still abstracting over the issue of partial chunks. This will wait until the first response data is received before creating a channel.

Termination behaviour: if the wire terminates while a receiver is still held, that receiver will be intelligently poisoned, and any remaining values will be yielded, before an error is returned that the wire was terminated.

Source

pub async fn wait_bytes(self) -> Result<Vec<Vec<u8>>, Error>

Same as .wait(), but this works directly with bytes. This will return the chunks in the message (to learn more about chunks, see Interface).

Termination behaviour: if the wire terminates during this call, the completion lock on the message this waits for will be explicitly poisoned, causing this call to fail with [Error::LockPoisoned].

Source

pub fn into_response_idx(self) -> IpfiInteger

Turns this call handle into the response index that can be used directly with the Interface. This allows using lower-level methods on the interface that aren’t accessible on the call handle, but you generally won’t need these.

This is typically required when you want to check whether or not a call handle is ready to yield.

Warning: calling this will remove the underlying response index from a list the Wire maintains of response buffers that haven’t been accessed yet. It uses this list to auto-poison those messages’ completion locks so that waiting handles don’t hang forever if the wire terminates, but, once this is called, that tracking can no longer occur! If you call this method, you should be extra careful about how you handle a terminating wire, as there will be no automatic poisoning of this response buffer anymore!

Auto Trait Implementations§

§

impl<'a> Freeze for CallHandle<'a>

§

impl<'a> !RefUnwindSafe for CallHandle<'a>

§

impl<'a> Send for CallHandle<'a>

§

impl<'a> Sync for CallHandle<'a>

§

impl<'a> Unpin for CallHandle<'a>

§

impl<'a> !UnwindSafe for CallHandle<'a>

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