pub struct DataLoadRequest<'a, Key: Send + 'static, Data: ServiceData> { /* private fields */ }
Expand description

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§

source§

impl<'a, Key: Send, Data: ServiceData> DataLoadRequest<'a, Key, Data>

source

pub fn key(&self) -> &Key

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

source

pub fn take_key(&mut self) -> Key

source

pub fn resolve(self, data: Data)

Resolves the data load request with the given data.

source

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

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

source§

impl<'a, Data: ServiceData, Key: Send + 'static> DataLoadRequest<'a, Key, Data>

source

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

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.

source§

impl<'a, Key: Send, Data: ServiceData + Default> DataLoadRequest<'a, Key, Data>

source

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

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

Trait Implementations§

source§

impl<'a, Key: Send, Data: ServiceData> Drop for DataLoadRequest<'a, Key, Data>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, Key, Data> Freeze for DataLoadRequest<'a, Key, Data>
where Key: Freeze,

§

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

§

impl<'a, Key, Data> Send for DataLoadRequest<'a, Key, Data>

§

impl<'a, Key, Data> Sync for DataLoadRequest<'a, Key, Data>
where Key: Sync,

§

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

§

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

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

§

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

§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V