1 /*
2  * hunt-amqp: AMQP library for D programming language, based on hunt-net.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 module hunt.amqp.streams.Tracker;
12 import hunt.proton.amqp.transport.DeliveryState;
13 import hunt.proton.message.Message;
14 
15 import hunt.amqp.Handler;
16 import hunt.amqp.streams.impl.TrackerImpl;
17 
18 interface Tracker {
19 
20   /**
21    * Creates a tracker for sending a message.
22    *
23    * @param message
24    *          the message
25    * @return the tracker
26    */
27   static Tracker create(Message message) {
28     return new TrackerImpl(message, null);
29   }
30 
31   /**
32    * Creates a tracker for sending a message, providing a handler that is
33    * called when disposition updates are received for the message delivery.
34    *
35    * @param message
36    *          the message
37    * @param onUpdated
38    *          the onUpdated handler
39    * @return the tracker
40    */
41   static Tracker create(Message message, Handler!Tracker onUpdated) {
42     return new TrackerImpl(message, onUpdated);
43   }
44 
45   // ===========================
46 
47   /**
48    * Retrieves the message being tracked.
49    *
50    * @return the message
51    */
52   Message message();
53 
54   /**
55    * Returns whether the message was accepted.
56    *
57    * Equivalent to: tracker.getRemoteState() instanceof Accepted;
58    *
59    * @return true if the message was accepted.
60    */
61   bool isAccepted();
62 
63   /**
64    * Returns whether the message was settled by the peer.
65    *
66    * @return true if the message was settled.
67    */
68   bool isRemotelySettled();
69 
70   /**
71    * Gets the current remote state for the delivery.
72    *
73    * @return the remote delivery state
74    */
75   DeliveryState getRemoteState();
76 }