wireshift_core/ops/
cancel.rs1use crate::error::Result;
3use crate::op::{CompletionPayload, Op, OpDescriptor};
4
5#[derive(Clone, Copy, Debug)]
14pub struct Cancel {
15 target: u64,
16}
17
18impl Cancel {
19 #[must_use]
21 pub fn new(target: u64) -> Self {
22 Self { target }
23 }
24
25 #[must_use]
27 pub fn target(self) -> u64 {
28 self.target
29 }
30}
31
32impl Op for Cancel {
33 type Output = ();
34
35 fn name(&self) -> &'static str {
36 "cancel"
37 }
38
39 fn into_descriptor(self) -> Result<OpDescriptor> {
40 Ok(OpDescriptor::Cancel {
41 target: self.target,
42 })
43 }
44
45 fn map_completion(payload: CompletionPayload) -> Result<Self::Output> {
46 match payload {
47 CompletionPayload::Unit => Ok(()),
48 other => Err(crate::error::Error::completion(
49 format!("cancel received unexpected completion payload: {other:?}"),
50 "ensure the backend routes cancel completions as unit payloads",
51 )),
52 }
53 }
54}