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 moreSource§impl<'de, Payload, ErrData> Deserialize<'de> for ResponsePacket<Payload, ErrData>where
Payload: Deserialize<'de>,
ErrData: Deserialize<'de>,
impl<'de, Payload, ErrData> Deserialize<'de> for ResponsePacket<Payload, ErrData>where
Payload: Deserialize<'de>,
ErrData: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<Payload, ErrData> From<Vec<Response<Payload, ErrData>>> for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> From<Vec<Response<Payload, ErrData>>> for ResponsePacket<Payload, ErrData>
Source§impl<Payload, ErrData> FromIterator<Response<Payload, ErrData>> for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> FromIterator<Response<Payload, ErrData>> for ResponsePacket<Payload, ErrData>
Auto Trait Implementations§
impl<Payload, ErrData> Freeze for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> RefUnwindSafe for ResponsePacket<Payload, ErrData>where
Payload: RefUnwindSafe,
ErrData: RefUnwindSafe,
impl<Payload, ErrData> Send for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> Sync for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> Unpin for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> UnwindSafe for ResponsePacket<Payload, ErrData>where
Payload: UnwindSafe,
ErrData: 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
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
)