twizzler_driver/request/
summary.rs

1#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
2/// A summary of the result of submitting a collection of requests to the request manager and having
3/// the device respond. Contains responses.
4pub enum SubmitSummaryWithResponses<R> {
5    /// A vector of responses in the same order as the submitted requests.
6    Responses(Vec<R>),
7    /// At least one error occurred. The usize value is the index of the first error.
8    Errors(usize, Vec<R>),
9    /// The request engine was shutdown while the requests were inflight.
10    Shutdown,
11}
12
13#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
14pub(crate) enum AnySubmitSummary<R> {
15    Done,
16    Responses(Vec<R>),
17    Errors(usize, Vec<R>),
18    Shutdown,
19}
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
22/// A summary of the result of submitting a collection of requests to the request manager and having
23/// the device respond. Does not contain responses.
24pub enum SubmitSummary {
25    /// All requests completed successfully.
26    Done,
27    /// At least one error occurred. The usize value is the index of the first error.
28    Errors(usize),
29    /// The request engine was shutdown while the requests were inflight.
30    Shutdown,
31}
32
33impl<R> From<AnySubmitSummary<R>> for SubmitSummary {
34    fn from(a: AnySubmitSummary<R>) -> Self {
35        match a {
36            AnySubmitSummary::Done => SubmitSummary::Done,
37            AnySubmitSummary::Responses(_) => panic!("cannot convert"),
38            AnySubmitSummary::Errors(e, _) => SubmitSummary::Errors(e),
39            AnySubmitSummary::Shutdown => SubmitSummary::Shutdown,
40        }
41    }
42}
43
44impl<R> From<AnySubmitSummary<R>> for SubmitSummaryWithResponses<R> {
45    fn from(a: AnySubmitSummary<R>) -> Self {
46        match a {
47            AnySubmitSummary::Responses(r) => SubmitSummaryWithResponses::Responses(r),
48            AnySubmitSummary::Done => panic!("cannot convert"),
49            AnySubmitSummary::Errors(e, r) => SubmitSummaryWithResponses::Errors(e, r),
50            AnySubmitSummary::Shutdown => SubmitSummaryWithResponses::Shutdown,
51        }
52    }
53}