feat: add QBIN2 V4 encoded field ingress
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
56
include/mbgl/particle/ingress/qbin_v2_decoder.hpp
Normal file
56
include/mbgl/particle/ingress/qbin_v2_decoder.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/particle/field/field_profile_validator.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string>
|
||||
|
||||
namespace mbgl::particle::ingress {
|
||||
|
||||
struct EncodedFieldRuntimeMetadata {
|
||||
std::string fieldID;
|
||||
uint64_t generation = 0;
|
||||
uint64_t dataVersion = 0;
|
||||
};
|
||||
|
||||
enum class QbinV2DecodeErrorCode : uint8_t {
|
||||
Accepted, InvalidRuntimeMetadata, InputTooSmall, BadMagic, UnsupportedVersion, UnsupportedLayout,
|
||||
UnsupportedProjection, UnsupportedSampleOrder, UnsupportedGridRegistration, InvalidHeader, InvalidBounds,
|
||||
InvalidTime, LimitExceeded, LengthMismatch, ReservedNonZero, InvalidDescriptor,
|
||||
NonCanonicalDescriptorOrder, DuplicatePlaneKey, NonCanonicalPacking, NonZeroPadding, CrcMismatch,
|
||||
InvalidValidity, InvalidCellPayload,
|
||||
};
|
||||
|
||||
struct QbinV2DecodeResult {
|
||||
QbinV2DecodeErrorCode code = QbinV2DecodeErrorCode::InvalidHeader;
|
||||
std::string detail;
|
||||
std::shared_ptr<const DecodedFieldFrame> frame;
|
||||
bool accepted() const { return code == QbinV2DecodeErrorCode::Accepted && static_cast<bool>(frame); }
|
||||
};
|
||||
|
||||
class QbinV2Decoder final {
|
||||
public:
|
||||
static QbinV2DecodeResult decode(const EncodedFieldRuntimeMetadata&, std::span<const uint8_t>);
|
||||
};
|
||||
|
||||
enum class EncodedFieldIngressCode : uint8_t { Accepted, DecodeRejected, ContractMissing, ContractRejected };
|
||||
|
||||
struct EncodedFieldIngressResult {
|
||||
EncodedFieldIngressCode code = EncodedFieldIngressCode::DecodeRejected;
|
||||
std::string detail;
|
||||
QbinV2DecodeErrorCode decodeCode = QbinV2DecodeErrorCode::InvalidHeader;
|
||||
FieldProfileValidationCode contractCode = FieldProfileValidationCode::InvalidContract;
|
||||
std::shared_ptr<const DecodedFieldFrame> frame;
|
||||
bool accepted() const { return code == EncodedFieldIngressCode::Accepted && static_cast<bool>(frame); }
|
||||
};
|
||||
|
||||
class EncodedFieldIngress final {
|
||||
public:
|
||||
static EncodedFieldIngressResult decodeAndValidate(const EncodedFieldRuntimeMetadata&,
|
||||
const ResolvedFieldProfileContract* contract,
|
||||
std::span<const uint8_t>);
|
||||
};
|
||||
|
||||
} // namespace mbgl::particle::ingress
|
||||
Reference in New Issue
Block a user