summaryrefslogtreecommitdiff
path: root/src/storage.h
blob: 68002fad0d2f50ac8990394276111dea18f91a1f (plain)
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
#pragma once

#include "erebos/storage.h"

#include <future>
#include <unordered_set>

namespace fs = std::filesystem;

using std::optional;
using std::shared_future;
using std::unordered_set;
using std::vector;

namespace erebos {

struct Storage::Priv
{
	static constexpr size_t CHUNK = 16384;

	fs::path root;

	fs::path objectPath(const Digest &) const;
	fs::path keyPath(const Digest &) const;
	optional<vector<uint8_t>> loadBytes(const Digest &) const;
	void storeBytes(const Digest &, const vector<uint8_t> &) const;
};

struct Ref::Priv
{
	Storage storage;
	Digest digest;

	shared_future<Object> object;
};

vector<Stored<Object>> collectStoredObjects(const Stored<Object> &);

}