[][src]Struct thingvellir::DataLoadRequest

#[must_use =
  "the data load request must be resolved or rejected, otherwise the operation will be considered aborted."]pub struct DataLoadRequest<Key, Data> { /* fields omitted */ }

The data load request is passed to [LoadFromUpstream::load] handler.

It contains methods to notify the shard that the data has finished loading, or has failed to load.

If the DataLoadRequest is dropped, without sending a result, the shard will receive an UpstreamError::OperationAborted for the given key being loaded. This prevents leaking load requests due to code error, where a code-path did not use the data load request.

Implementations

impl<Key, Data> DataLoadRequest<Key, Data>[src]

pub fn key(&self) -> &Key[src]

Returns a reference to the key that is currently being loaded.

pub fn resolve(self, data: Data)[src]

Resolves the data load request with the given data.

pub fn reject<E: Into<UpstreamError>>(self, error: E)[src]

Rejects the data load request with a given error. The error must be able to be converted into an UpstreamError.

impl<Key: Send + 'static, Data: ServiceData> DataLoadRequest<Key, Data>[src]

pub fn spawn<F: Future<Output = Result<Data, UpstreamError>> + Send + 'static>(
    self,
    fut: F
)
[src]

Convenience method to spawn a task to drive a future to completion, and capture that future's result in order to reject or resolve the data load request.

impl<Key: Send + 'static, Data: ServiceData + Default> DataLoadRequest<Key, Data>[src]

pub fn spawn_default<F: Future<Output = Result<Data, UpstreamError>> + Send + 'static>(
    self,
    fut: F
)
[src]

Similar to spawn, however, in event of encountering a UpstreamError::KeyNotFound, error will resolve with the value of Data::default.

Trait Implementations

impl<Key, Data> Drop for DataLoadRequest<Key, Data>[src]

Auto Trait Implementations

impl<Key, Data> !RefUnwindSafe for DataLoadRequest<Key, Data>

impl<Key, Data> Send for DataLoadRequest<Key, Data> where
    Data: Send,
    Key: Send

impl<Key, Data> Sync for DataLoadRequest<Key, Data> where
    Data: Send,
    Key: Send + Sync

impl<Key, Data> Unpin for DataLoadRequest<Key, Data> where
    Key: Unpin

impl<Key, Data> !UnwindSafe for DataLoadRequest<Key, Data>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,