blob: 0fc316bcf8b882a7a42c905289e90d44e0b2a467 [file] [log] [blame]
Kun Yi68c81142018-12-18 11:17:14 -08001#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7using std::size_t;
8using std::uint16_t;
9using std::uint32_t;
10using std::uint64_t;
11using std::uint8_t;
12
13namespace binstore
14{
15
16/**
17 * @class BinaryStoreInterface is an abstraction for a storage location.
18 * Each instance would be uniquely identified by a baseId string.
19 */
20class BinaryStoreInterface
21{
22 public:
23 virtual ~BinaryStoreInterface() = default;
24
25 virtual std::string getBaseBlobId() const = 0;
26 virtual std::vector<std::string> getBlobIds() const = 0;
27 virtual bool canHandleBlob(const std::string& blobId) const = 0;
Kun Yi38146a02018-12-18 21:54:26 -080028 virtual bool openOrCreateBlob(const std::string& blobId,
29 uint16_t flags) = 0;
Kun Yi68c81142018-12-18 11:17:14 -080030 virtual std::vector<uint8_t> read(uint32_t offset,
31 uint32_t requestedSize) = 0;
32 virtual bool write(uint32_t offset, const std::vector<uint8_t>& data) = 0;
33 virtual bool commit() = 0;
34 virtual bool close() = 0;
35 virtual bool stat() = 0;
36};
37
38} // namespace binstore