Struct icu_provider::response::DataResponse
source · 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: DataResponseMetadata
Metadata 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>
impl<M> Clone for DataResponse<M>
source§impl<M> Debug for DataResponse<M>
impl<M> Debug for DataResponse<M>
source§impl From<AnyResponse> for DataResponse<AnyMarker>
impl From<AnyResponse> for DataResponse<AnyMarker>
source§fn from(other: AnyResponse) -> Self
fn from(other: AnyResponse) -> Self
source§impl TryFrom<DataResponse<AnyMarker>> for AnyResponse
impl TryFrom<DataResponse<AnyMarker>> for AnyResponse
source§impl<M> TryFrom<DataResponse<M>> for DataPayload<M>where
M: DataMarker,
impl<M> TryFrom<DataResponse<M>> for DataPayload<M>where
M: DataMarker,
Auto Trait Implementations§
impl<M> Freeze for DataResponse<M>
impl<M> RefUnwindSafe for DataResponse<M>
impl<M> !Send for DataResponse<M>
impl<M> !Sync for DataResponse<M>
impl<M> Unpin for DataResponse<M>
impl<M> UnwindSafe for DataResponse<M>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)