blob: 11ca241a7bc2ddd4b1a74f86a694a044cce8e126 [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 Yic0adbc32018-12-18 22:35:29 -080030 virtual bool deleteBlob(const std::string& blobId) = 0;
Kun Yi68c81142018-12-18 11:17:14 -080031 virtual std::vector<uint8_t> read(uint32_t offset,
32 uint32_t requestedSize) = 0;
33 virtual bool write(uint32_t offset, const std::vector<uint8_t>& data) = 0;
34 virtual bool commit() = 0;
35 virtual bool close() = 0;
36 virtual bool stat() = 0;
37};
38
39} // namespace binstore