pub struct UnaryResponse<Resp> { /* private fields */ }Expand description
Response from a unary RPC call.
Contains the decoded response message along with response headers and trailing metadata.
Implementations§
Source§impl<Resp> UnaryResponse<Resp>
impl<Resp> UnaryResponse<Resp>
Sourcepub fn into_view(self) -> Resp
pub fn into_view(self) -> Resp
Consume the response, returning just the body.
For generated clients this is an OwnedView — zero-copy, move
semantics, suitable for keeping the decoded body around without
copying. Field access on it goes through
reborrow(); for inline reads prefer
view(), and for an owned struct use
into_owned().
Sourcepub fn into_parts(self) -> (HeaderMap, Resp, HeaderMap)
pub fn into_parts(self) -> (HeaderMap, Resp, HeaderMap)
Consume the response, returning (headers, body, trailers).
Source§impl<V> UnaryResponse<OwnedView<V>>where
V: MessageView<'static>,
Convenience for the common generated-client case where the body is an
OwnedView. Generated unary client methods always return this shape.
impl<V> UnaryResponse<OwnedView<V>>where
V: MessageView<'static>,
Convenience for the common generated-client case where the body is an
OwnedView. Generated unary client methods always return this shape.
Sourcepub fn into_owned(self) -> V::Owned
pub fn into_owned(self) -> V::Owned
Consume the response and return the fully-owned message, discarding headers and trailers.
This allocates and copies all borrowed fields (strings, bytes, nested
messages). Prefer zero-copy view access via
view() unless you need to pass the owned
struct to code that expects it, or store it in a collection.
let owned: FooResponse = client.foo(req).await?.into_owned();Infallible — see into_owned_parts() for
the argument.
Sourcepub fn into_owned_parts(self) -> (HeaderMap, V::Owned, HeaderMap)
pub fn into_owned_parts(self) -> (HeaderMap, V::Owned, HeaderMap)
Consume the response, returning (headers, owned message, trailers).
The metadata-preserving sibling of into_owned(),
for callers that also need the response’s header and trailer
metadata.
Infallible: OwnedView::to_owned_message cannot fail, because an
OwnedView can only come from buffa’s wire decoder and conversion
replays under the budget the decode already charged.
Source§impl<V> UnaryResponse<OwnedView<V>>where
V: ViewReborrow,
Zero-copy read access for OwnedView bodies whose view supports
reborrowing (every buffa-generated view does).
impl<V> UnaryResponse<OwnedView<V>>where
V: ViewReborrow,
Zero-copy read access for OwnedView bodies whose view supports
reborrowing (every buffa-generated view does).
Sourcepub fn view(&self) -> &V::Reborrowed<'_>
pub fn view(&self) -> &V::Reborrowed<'_>
Borrow the response message view, tied to &self.
Field access on the returned view is zero-copy:
let resp = client.foo(req).await?;
assert_eq!(resp.view().name, "expected"); // &str, no allocationSee also into_view() to keep the decoded
body and into_owned() for an owned
struct.