FlatImage
A configurable Linux containerization system
Loading...
Searching...
No Matches
ns_db::ns_bind Namespace Reference

Bind mount configuration management. More...

Classes

struct  Bind
 Represents a single bind mount from host to guest. More...
 
struct  Binds
 Container for multiple bind mount configurations. More...
 

Functions

 ENUM (Type, RO, RW, DEV)
 
Value< Bindsdeserialize (std::string_view raw_json)
 Deserializes JSON string into a Binds object.
 
Value< Bindsdeserialize (std::ifstream &stream_raw_json) noexcept
 Deserializes JSON from an input stream into a Binds object.
 
Value< Dbserialize (Binds const &binds) noexcept
 Serializes a Binds object into a JSON database.
 

Detailed Description

Bind mount configuration management.

Manages host-to-sandbox bind mount configurations with support for read-only (RO), read-write (RW), and device (DEV) mount types. Provides serialization/deserialization to JSON, mount indexing, and collection management for configuring filesystem bindings between the host system and sandboxed container.

Function Documentation

◆ deserialize() [1/2]

Value< Binds > ns_db::ns_bind::deserialize ( std::ifstream & stream_raw_json)
inlinenodiscardnoexcept

Deserializes JSON from an input stream into a Binds object.

Reads the entire contents of the input file stream into a string buffer and delegates to the string_view overload of deserialize() for parsing. This provides a convenient interface for reading bind configurations directly from file streams without manual buffer management.

Parameters
stream_raw_jsonInput file stream containing JSON bind mount data
Returns
Value<Binds> The deserialized Binds object on success, or error on read/parse failure

Definition at line 226 of file bind.hpp.

Here is the call graph for this function:

◆ deserialize() [2/2]

Value< Binds > ns_db::ns_bind::deserialize ( std::string_view raw_json)
inlinenodiscard

Deserializes JSON string into a Binds object.

Parses a JSON string containing bind mount configurations and constructs a Binds object. Each JSON entry should have "src", "dst", and "type" fields. The type field must be "ro" (read-only), "rw" (read-write), or "dev" (device). Entries with invalid indices are logged as warnings and skipped. Successfully parsed entries are added to the Binds collection with their respective indices, source paths, destination paths, and access types.

Parameters
raw_jsonThe JSON string containing bind mount configurations
Returns
Value<Binds> The deserialized Binds object on success, or error on parse failure

Definition at line 184 of file bind.hpp.

Here is the caller graph for this function:

◆ serialize()

Value< Db > ns_db::ns_bind::serialize ( Binds const & binds)
inlinenodiscardnoexcept

Serializes a Binds object into a JSON database.

Converts the Binds collection into a structured Db (JSON) object. Each bind mount is stored as a numbered entry with its index as the key. Each entry contains three fields: "src" (source path), "dst" (destination path), and "type" (access mode as "ro", "rw", or "dev"). The resulting Db can be dumped to a string or written to a file.

Parameters
bindsThe Binds object containing bind mount configurations to serialize
Returns
Value<Db> The JSON database representation on success, or error on failure

Definition at line 244 of file bind.hpp.

Here is the caller graph for this function: