aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppSendResult.h
blob: 451387ac261d4a19d26457839606065c2a9ff277 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-FileCopyrightText: 2021 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifndef QXMPPSENDRESULT_H
#define QXMPPSENDRESULT_H

#include "QXmppError.h"

#include <variant>

namespace QXmpp {

///
/// Describes the type of a packet sending error.
///
/// \since QXmpp 1.5
///
enum class SendError : uint8_t {
    /// The packet was written to the socket with no success (only happens when Stream Management is disabled).
    SocketWriteError,
    /// The packet couldn't be sent because the connection hasn't been (re)established.
    Disconnected,
    /// The packet couldn't be sent because prior encryption failed.
    EncryptionError,
};

///
/// A struct indicating success when sending packets
///
/// \since QXmpp 1.5
///
struct SendSuccess
{
    /// Indicates whether the packet has been acknowledged by the other peer.
    bool acknowledged = false;
};

///
/// A variant containing either a SendSuccess object or a QXmppError.
///
/// The QXmppError will likely contain a SendError.
///
using SendResult = std::variant<SendSuccess, QXmppError>;

}  // namespace QXmpp

#endif  // QXMPPSENDRESULT_H