aboutsummaryrefslogtreecommitdiff
path: root/zenhttp/httpshared.h
blob: 92c1ef9c60c1159b1f014ace2cb20f90618c2573 (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
49
50
51
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <zencore/iobuffer.h>
#include <zencore/iohash.h>

#include <functional>

namespace zen {

class IoBuffer;
class CbPackage;
class CompositeBuffer;

struct CbPackageHeader
{
	uint32_t HeaderMagic;
	uint32_t AttachmentCount;
	uint32_t Reserved1;
	uint32_t Reserved2;
};

static_assert(sizeof(CbPackageHeader) == 16);

static constinit uint32_t kCbPkgMagic = 0xaa77aacc;

struct CbAttachmentEntry
{
	uint64_t AttachmentSize;
	uint32_t Flags;
	IoHash	 AttachmentHash;

	enum
	{
		kIsCompressed = (1u << 0),	// Is marshaled using compressed buffer storage format
		kIsObject	  = (1u << 1),	// Is compact binary object
	};
};

static_assert(sizeof(CbAttachmentEntry) == 32);

std::vector<IoBuffer> FormatPackageMessage(const CbPackage& Data);
CompositeBuffer		  FormatPackageMessageBuffer(const CbPackage& Data);
CbPackage			  ParsePackageMessage(
				IoBuffer												  Payload,
				std::function<IoBuffer(const IoHash& Cid, uint64_t Size)> CreateBuffer = [](const IoHash&, uint64_t Size) -> IoBuffer {
		return IoBuffer{Size};
				});

}  // namespace zen