31ENUM(Type, RO, RW, DEV);
96 std::vector<Bind> m_binds;
99 std::vector<Bind>
const&
get()
const;
101 void erase(
size_t index);
102 bool empty()
const noexcept;
115[[nodiscard]]
inline std::vector<Bind>
const&
Binds::get()
const
117 return this->m_binds;
132 m_binds.push_back(bind);
147 if (std::erase_if(m_binds, [&](
auto&& bind){
return bind.index == index; }) > 0)
149 logger(
"I::Erase element with index '{}'", index);
153 logger(
"I::No element with index '{}' found", index);
155 for(
long i{};
auto& bind : m_binds) { bind.index = i++; }
168 return m_binds.empty();
190 for(
auto [key,value] : db.items())
192 auto type = Pop(value(
"type").
template value<std::string>());
193 if (
auto index_result = Catch(std::stoull(key)))
195 binds.m_binds.push_back(
Bind
197 .index = index_result.value(),
198 .path_src = Pop(value(
"src").
template value<std::string>()),
199 .path_dst = Pop(value(
"dst").
template value<std::string>()),
200 .type = (type ==
"ro")? Type::RO
201 : (type ==
"rw")? Type::RW
202 : (type ==
"rw")? Type::DEV
208 logger(
"W::Failed to parse bind index '{}'", key);
228 std::stringstream ss;
229 ss << stream_raw_json.rdbuf();
247 for (
auto&& bind : binds.get())
249 db(std::to_string(bind.index))(
"src") = bind.path_src;
250 db(std::to_string(bind.index))(
"dst") = bind.path_dst;
251 db(std::to_string(bind.index))(
"type") = (bind.type == Type::RO)?
"ro" : (bind.type == Type::RW)?
"rw" :
"dev";
A type-safe wrapper around nlohmann::json for database operations.
A database that interfaces with nlohmann json.
Custom enumeration class.
Enhanced error handling framework built on std::expected.
#define logger(fmt,...)
Compile-time log level dispatch macro with automatic location capture.
Bind mount configuration management.
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< Db > from_string(S &&s)
Parses a JSON string and creates a Db object.
Enhanced expected type with integrated logging capabilities.
Represents a single bind mount from host to guest.
fs::path path_dst
Destination path inside the sandbox.
size_t index
Sequential index of this bind mount in the collection.
Type type
Access type for this bind mount.
fs::path path_src
Source path on the host system.
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.
friend Value< Binds > deserialize(std::string_view raw_json)
Deserializes JSON string into a Binds object.
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.