pub struct NetworkStore { /* private fields */ }Expand description
Storage for network profiles.
Profiles are stored as individual JSON files in a directory, similar to identities.
The directory location can be overridden via SDKT_NETWORK_DIR environment variable
for testing or custom configurations; otherwise it uses the OS config directory
(~/.config/sdkt/networks on Linux, matching the IdentityStore convention).
Implementations§
Source§impl NetworkStore
impl NetworkStore
Sourcepub fn new() -> Result<Self, StorageError>
pub fn new() -> Result<Self, StorageError>
Create a new network store.
If the SDKT_NETWORK_DIR environment variable is set to a non-empty value,
it is used as the base directory. This is the canonical cross-platform way for
tests and CI to isolate the network store (mirrors SDKT_IDENTITY_DIR).
Otherwise, falls back to the OS config directory via directories::ProjectDirs:
- Linux:
$XDG_CONFIG_HOME/sdkt/networksor~/.config/sdkt/networks - macOS:
~/Library/Application Support/sdkt/networks - Windows:
%APPDATA%\sdkt\networks
Sourcepub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self, StorageError>
pub fn with_dir<P: AsRef<Path>>(dir: P) -> Result<Self, StorageError>
Create a network store rooted at an explicit directory.
The directory is created if it does not already exist. This is the injection point used by tests and by callers that want to manage profiles in a non-default location without touching environment state.
Sourcepub fn list(&self) -> Result<Vec<NetworkProfile>, StorageError>
pub fn list(&self) -> Result<Vec<NetworkProfile>, StorageError>
List all network profiles.
Sourcepub fn get(&self, name: &str) -> Result<NetworkProfile, StorageError>
pub fn get(&self, name: &str) -> Result<NetworkProfile, StorageError>
Get a specific network profile by name.
Sourcepub fn add(&self, profile: NetworkProfile) -> Result<(), StorageError>
pub fn add(&self, profile: NetworkProfile) -> Result<(), StorageError>
Add or update a network profile.
Sourcepub fn as_map(&self) -> Result<HashMap<String, NetworkProfile>, StorageError>
pub fn as_map(&self) -> Result<HashMap<String, NetworkProfile>, StorageError>
Get all profiles as a map keyed by profile name.