pub struct ResponseEnvelope<T, M> {
pub data: T,
pub meta: M,
}Expand description
A fully typed success-response envelope.
Both data and meta remain concrete generic schema arguments. Products
should define DTOs for them rather than substituting serde_json::Value,
so generated clients retain the complete response contract. A paginated
response uses Vec<ItemDto> as T and a product-owned pagination metadata
DTO as M.
Fields§
§data: TThe typed response payload.
meta: MTyped response metadata, such as request ID and pagination cursor.
Implementations§
Source§impl<T, M> ResponseEnvelope<T, M>
impl<T, M> ResponseEnvelope<T, M>
Sourcepub const fn new(data: T, meta: M) -> ResponseEnvelope<T, M>
pub const fn new(data: T, meta: M) -> ResponseEnvelope<T, M>
Creates a fully typed response envelope.
Sourcepub fn map<U>(self, map: impl FnOnce(T) -> U) -> ResponseEnvelope<U, M>
pub fn map<U>(self, map: impl FnOnce(T) -> U) -> ResponseEnvelope<U, M>
Maps the payload without weakening the metadata type.
Trait Implementations§
Source§impl<T, M> Clone for ResponseEnvelope<T, M>
impl<T, M> Clone for ResponseEnvelope<T, M>
Source§fn clone(&self) -> ResponseEnvelope<T, M>
fn clone(&self) -> ResponseEnvelope<T, M>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, M> Debug for ResponseEnvelope<T, M>
impl<T, M> Debug for ResponseEnvelope<T, M>
Source§impl<'de, T, M> Deserialize<'de> for ResponseEnvelope<T, M>where
T: Deserialize<'de>,
M: Deserialize<'de>,
impl<'de, T, M> Deserialize<'de> for ResponseEnvelope<T, M>where
T: Deserialize<'de>,
M: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ResponseEnvelope<T, M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ResponseEnvelope<T, M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T, M> PartialEq for ResponseEnvelope<T, M>
impl<T, M> PartialEq for ResponseEnvelope<T, M>
Source§impl<T, M> Serialize for ResponseEnvelope<T, M>
impl<T, M> Serialize for ResponseEnvelope<T, M>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<T, M> StructuralPartialEq for ResponseEnvelope<T, M>
Auto Trait Implementations§
impl<T, M> Freeze for ResponseEnvelope<T, M>
impl<T, M> RefUnwindSafe for ResponseEnvelope<T, M>where
T: RefUnwindSafe,
M: RefUnwindSafe,
impl<T, M> Send for ResponseEnvelope<T, M>
impl<T, M> Sync for ResponseEnvelope<T, M>
impl<T, M> Unpin for ResponseEnvelope<T, M>
impl<T, M> UnsafeUnpin for ResponseEnvelope<T, M>where
T: UnsafeUnpin,
M: UnsafeUnpin,
impl<T, M> UnwindSafe for ResponseEnvelope<T, M>where
T: UnwindSafe,
M: UnwindSafe,
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
Mutably borrows from an owned value. Read more