11#include <promeki/config.h>
12#if PROMEKI_ENABLE_MDNS
21PROMEKI_NAMESPACE_BEGIN
74class MdnsServiceType {
76 PROMEKI_DATATYPE(MdnsServiceType, DataTypeMdnsServiceType, 1)
79 Error writeToStream(DataStream &s) const;
81 template <uint32_t V> static Result<MdnsServiceType> readFromStream(DataStream &s);
91 enum class Protocol : uint8_t {
98 static constexpr const char *DefaultDomain =
"local";
101 static constexpr int MaxAppLabelLen = 15;
104 MdnsServiceType() =
default;
121 MdnsServiceType(
const String &app, Protocol proto,
122 const String &domain = String(DefaultDomain));
137 static Result<MdnsServiceType> fromString(
const String &s);
140 const String &app()
const {
return _app; }
143 Protocol proto()
const {
return _proto; }
146 const String &domain()
const {
return _domain; }
149 bool isValid()
const {
return _proto != Protocol::Invalid && !_app.isEmpty(); }
158 String toString()
const;
167 String toFqdn()
const;
182 String toSubtypeBrowseFqdn(
const String &subtype)
const;
185 static String protocolToString(Protocol p);
188 static Protocol protocolFromString(
const String &s);
191 bool operator==(
const MdnsServiceType &other)
const;
192 bool operator!=(
const MdnsServiceType &other)
const {
return !(*
this == other); }
193 bool operator<(
const MdnsServiceType &other)
const;
197 Protocol _proto = Protocol::Invalid;
198 String _domain = String(DefaultDomain);
202TextStream &operator<<(TextStream &stream,
const MdnsServiceType &t);