pub struct DataResponse<M>where
    M: DataMarker,{
    pub metadata: DataResponseMetadata,
    pub payload: Option<DataPayload<M>>,
}Expand description
A response object containing an object as payload and metadata about it.
Fields§
§metadata: DataResponseMetadataMetadata about the returned object.
payload: Option<DataPayload<M>>The object itself; None if it was not loaded.
Implementations§
Source§impl<M> DataResponse<M>where
    M: DataMarker,
 
impl<M> DataResponse<M>where
    M: DataMarker,
Sourcepub fn take_payload(self) -> Result<DataPayload<M>, DataError>
 
pub fn take_payload(self) -> Result<DataPayload<M>, DataError>
Takes ownership of the underlying payload. Error if not present.
To take the metadata, too, use Self::take_metadata_and_payload().
Sourcepub fn take_metadata_and_payload(
    self,
) -> Result<(DataResponseMetadata, DataPayload<M>), DataError>
 
pub fn take_metadata_and_payload( self, ) -> Result<(DataResponseMetadata, DataPayload<M>), DataError>
Takes ownership of the underlying metadata and payload. Error if payload is not present.
Sourcepub fn cast<M2>(self) -> DataResponse<M2>where
    M2: DataMarker<Yokeable = M::Yokeable>,
 
pub fn cast<M2>(self) -> DataResponse<M2>where
    M2: DataMarker<Yokeable = M::Yokeable>,
Convert between two DataMarker types that are compatible with each other
with compile-time type checking.
This happens if they both have the same DataMarker::Yokeable type.
Can be used to erase the key of a data payload in cases where multiple keys correspond to the same data struct.
For runtime dynamic casting, use DataPayload::dynamic_cast_mut().
Source§impl<M> DataResponse<M>
 
impl<M> DataResponse<M>
Sourcepub fn wrap_into_any_response(self) -> AnyResponse
 
pub fn wrap_into_any_response(self) -> AnyResponse
Moves the inner DataPayload to the heap (requiring an allocation) and returns it as an
erased AnyResponse.
Trait Implementations§
Source§impl<M> Clone for DataResponse<M>
Cloning a DataResponse is generally a cheap operation.
See notes in the Clone impl for Yoke.
 
impl<M> Clone for DataResponse<M>
Cloning a DataResponse is generally a cheap operation.
See notes in the Clone impl for Yoke.
§Examples
use icu_provider::hello_world::*;
use icu_provider::prelude::*;
let resp1: DataResponse<HelloWorldV1Marker> = todo!();
let resp2 = resp1.clone();