32namespace fs = std::filesystem;
46 return (it == std::ranges::end(binds.
get()))? -1 : it->index;
61 reserved_data.empty()?
"{}" : reserved_data
87 , ns_db::ns_bind::Type bind_type
88 , fs::path
const& path_src
89 , fs::path
const& path_dst
97 .index = get_highest_index(binds) + 1,
103 logger(
"I::Binding index is '{}'", bind.index);
105 Pop(
db_write(path_file_binary, binds));
116[[nodiscard]]
inline Value<void> del(fs::path
const& path_file_binary, uint64_t index)
124 Pop(
db_write(path_file_binary, binds));
137 if(not binds.
empty())
Used to manage the bindings from the host to the sandbox.
A database that interfaces with nlohmann json.
#define logger(fmt,...)
Compile-time log level dispatch macro with automatic location capture.
uint64_t get_highest_index(ns_db::ns_bind::Binds const &binds)
Get the highest index object.
Bind mount command implementation.
Value< void > list(fs::path const &path_file_binary)
List bindings from the given bindings database.
Value< void > del(fs::path const &path_file_binary, uint64_t index)
Deletes a binding from the database.
Value< void > add(fs::path const &path_file_binary, ns_db::ns_bind::Type bind_type, fs::path const &path_src, fs::path const &path_dst)
Adds a binding instruction to the binding database.
Value< ns_db::ns_bind::Binds > db_read(fs::path const &path_file_binary)
Reads data from the reserved space.
Value< void > db_write(fs::path const &path_file_binary, ns_db::ns_bind::Binds const &binds)
Writes data to the reserved space.
Value< Binds > deserialize(std::string_view raw_json)
Deserializes JSON string into a Binds object.
Value< Db > serialize(Binds const &binds) noexcept
Serializes a Binds object into a JSON database.
Value< void > write(fs::path const &path_file_binary, std::string_view const &json)
Writes the bindings json string to the target binary.
Value< std::string > read(fs::path const &path_file_binary)
Reads the bindings json string from the target binary.
Manages the bindings reserved space.
Enhanced expected type with integrated logging capabilities.
Represents a single bind mount from host to guest.
Container for multiple bind mount configurations.
void erase(size_t index)
Removes a bind mount by its index.
bool empty() const noexcept
Checks whether the bind mount collection is empty.
std::vector< Bind > const & get() const
Retrieves the current list of bind mounts.
void push_back(Bind const &bind)
Appends a new bind mount to the collection.