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
)