pub enum ResponsePacket<Payload = Box<RawValue>, ErrData = Box<RawValue>> {
Single(Response<Payload, ErrData>),
Batch(Vec<Response<Payload, ErrData>>),
}
Expand description
A ResponsePacket
is a Response
or a batch of responses.
Variants§
Single(Response<Payload, ErrData>)
A single response.
Batch(Vec<Response<Payload, ErrData>>)
A batch of responses.
Implementations§
Source§impl ResponsePacket<&RawValue, &RawValue>
impl ResponsePacket<&RawValue, &RawValue>
Sourcepub fn into_owned(self) -> ResponsePacket
pub fn into_owned(self) -> ResponsePacket
Convert this borrowed response packet into an owned packet by copying the data from the deserializer (if necessary).
Source§impl<Payload, ErrData> ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> ResponsePacket<Payload, ErrData>
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true
if the response payload is a success.
For batch responses, this returns true
if all responses are successful.
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Returns true
if the response payload is an error.
For batch responses, this returns true
there’s at least one error response.
Sourcepub fn as_error(&self) -> Option<&ErrorPayload<ErrData>>
pub fn as_error(&self) -> Option<&ErrorPayload<ErrData>>
Returns the ErrorPayload if the response is an error.
For batch responses, this returns the first error response.
Sourcepub fn iter_errors(&self) -> impl Iterator<Item = &ErrorPayload<ErrData>> + '_
pub fn iter_errors(&self) -> impl Iterator<Item = &ErrorPayload<ErrData>> + '_
Returns an iterator over the ErrorPayloads in the response.
Sourcepub fn responses_by_ids(
&self,
ids: &HashSet<Id>,
) -> Vec<&Response<Payload, ErrData>>
pub fn responses_by_ids( &self, ids: &HashSet<Id>, ) -> Vec<&Response<Payload, ErrData>>
Find responses by a list of IDs.
This is intended to be used in conjunction with
RequestPacket::subscription_request_ids
to identify subscription
responses.
§Note
- Responses are not guaranteed to be in the same order.
- Responses are not guaranteed to be in the set.
- If the packet contains duplicate IDs, both will be found.
Trait Implementations§
Source§impl<Payload: Clone, ErrData: Clone> Clone for ResponsePacket<Payload, ErrData>
impl<Payload: Clone, ErrData: Clone> Clone for ResponsePacket<Payload, ErrData>
Source§fn clone(&self) -> ResponsePacket<Payload, ErrData>
fn clone(&self) -> ResponsePacket<Payload, ErrData>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more