azure-core-amqp
Loading...
Searching...
No Matches
amqp_header.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include <azure/core/nullable.hpp>
7
8#include <chrono>
9#include <cstddef>
10#include <cstdint>
11#include <exception>
12#include <stdexcept>
13#include <vector>
14
15namespace Azure { namespace Core { namespace Amqp { namespace Models {
23 struct MessageHeader final
24 {
26 MessageHeader() = default;
28 ~MessageHeader() = default;
29
31 MessageHeader(MessageHeader&& other) = default;
32
35
37 MessageHeader(MessageHeader const& other) = default;
38
40 MessageHeader& operator=(MessageHeader const& other) = default;
41
47 bool operator==(MessageHeader const& that) const noexcept;
48
54 bool Durable{false};
55
61 std::uint8_t Priority{4}; // Default priority is 4.
62
68 Nullable<std::chrono::milliseconds> TimeToLive;
69
75 bool IsFirstAcquirer{false};
76
83 std::uint32_t DeliveryCount{0};
84
90 bool ShouldSerialize() const noexcept;
91
96 static size_t GetSerializedSize(MessageHeader const& messageHeader);
97
104 static std::vector<uint8_t> Serialize(MessageHeader const& messageHeader);
105
110 static MessageHeader Deserialize(std::uint8_t const* data, size_t size);
111 };
112
113 std::ostream& operator<<(std::ostream&, MessageHeader const&);
114
115}}}} // namespace Azure::Core::Amqp::Models
The message header section carries standard delivery details about the transfer of a message through ...
Definition amqp_header.hpp:24
std::uint32_t DeliveryCount
The number of unsuccessful previous attempts to deliver this message.
Definition amqp_header.hpp:83
MessageHeader(MessageHeader &&other)=default
Move constructor.
bool operator==(MessageHeader const &that) const noexcept
Compare two AMQP Message Headers for equality.
Definition amqp_header.cpp:27
static std::vector< uint8_t > Serialize(MessageHeader const &messageHeader)
Serializes this MessageHeader into a vector of bytes.
Definition amqp_header.cpp:144
MessageHeader(MessageHeader const &other)=default
Copy constructor.
bool Durable
True if the message is considered "durable".
Definition amqp_header.hpp:54
Nullable< std::chrono::milliseconds > TimeToLive
If present, defines the time to live for the message.
Definition amqp_header.hpp:68
bool IsFirstAcquirer
If true, the message has not been acquired by any other link.
Definition amqp_header.hpp:75
static MessageHeader Deserialize(std::uint8_t const *data, size_t size)
Deserializes a vector of bytes into a MessageHeader.
Definition amqp_header.cpp:152
std::uint8_t Priority
Priority of the message.
Definition amqp_header.hpp:61
MessageHeader & operator=(MessageHeader const &other)=default
Copy assignment operator.
static size_t GetSerializedSize(MessageHeader const &messageHeader)
Returns the serialized size of this MessageHeader.
Definition amqp_header.cpp:136
MessageHeader()=default
Default constructor.
bool ShouldSerialize() const noexcept
Returns true if this MessageHeader should be serialized into an AMQP message.
Definition amqp_header.cpp:130
MessageHeader & operator=(MessageHeader &&other)=default
Move assignment operator.