add file2 experimentally to the backend interface
This commit is contained in:
parent
bccf7680e6
commit
d1bed239a6
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "./serializer_json.hpp"
|
#include "./serializer_json.hpp"
|
||||||
|
|
||||||
|
#include <solanaceae/file/file2.hpp>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp> // this sucks
|
#include <nlohmann/json.hpp> // this sucks
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -70,6 +72,10 @@ bool StorageBackendI::write(Object o, const ByteSpan data) {
|
|||||||
return write(o, fn_cb);
|
return write(o, fn_cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<File2I> StorageBackendI::file2(Object o, FILE2_FLAGS flags) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
ObjectStore2::ObjectStore2(void) {
|
ObjectStore2::ObjectStore2(void) {
|
||||||
// HACK: set them up independently
|
// HACK: set them up independently
|
||||||
auto& sjc = _reg.ctx().emplace<SerializerJsonCallbacks<Object>>();
|
auto& sjc = _reg.ctx().emplace<SerializerJsonCallbacks<Object>>();
|
||||||
|
@ -15,6 +15,7 @@ using ObjectHandle = entt::basic_handle<ObjectRegistry>;
|
|||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
struct ObjectStore2;
|
struct ObjectStore2;
|
||||||
|
struct File2I;
|
||||||
|
|
||||||
struct StorageBackendI {
|
struct StorageBackendI {
|
||||||
// OR or OS ?
|
// OR or OS ?
|
||||||
@ -35,6 +36,15 @@ struct StorageBackendI {
|
|||||||
using read_from_storage_put_data_cb = void(const ByteSpan buffer);
|
using read_from_storage_put_data_cb = void(const ByteSpan buffer);
|
||||||
virtual bool read(Object o, std::function<read_from_storage_put_data_cb>& data_cb) = 0;
|
virtual bool read(Object o, std::function<read_from_storage_put_data_cb>& data_cb) = 0;
|
||||||
|
|
||||||
|
// ========== File2 interop ==========
|
||||||
|
enum FILE2_FLAGS : uint32_t {
|
||||||
|
FILE2_READ = 1u << 0,
|
||||||
|
FILE2_WRITE = 1u << 1,
|
||||||
|
};
|
||||||
|
// TODO: stronger requirements
|
||||||
|
// the backend might decide to not support writing using file2, if it's eg. zstd compressed
|
||||||
|
// backends might only support a single file2 instance per object!
|
||||||
|
std::unique_ptr<File2I> file2(Object o, FILE2_FLAGS flags); // default does nothing
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace ObjectStore::Events {
|
namespace ObjectStore::Events {
|
||||||
|
Loading…
Reference in New Issue
Block a user