twizzler_driver/request/
response_info.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2/// Information about a response from the driver. Sent by the driver back to the request manager.
3pub struct ResponseInfo<R> {
4    resp: R,
5    is_err: bool,
6    id: u64,
7}
8
9impl<R: Send> ResponseInfo<R> {
10    /// Construct a new ResponseInfo.
11    pub fn new(resp: R, id: u64, is_err: bool) -> Self {
12        Self { resp, is_err, id }
13    }
14
15    /// Is this response an error?
16    pub fn is_err(&self) -> bool {
17        self.is_err
18    }
19
20    /// Get a reference to the response data.
21    pub fn data(&self) -> &R {
22        &self.resp
23    }
24
25    /// Convert this ResponseInfo into the inner response data.
26    pub fn into_inner(self) -> R {
27        self.resp
28    }
29
30    /// Get the ID of the response (and thus the request with which it is paired).
31    pub fn id(&self) -> u64 {
32        self.id
33    }
34}