Skip to main content

NetworkStore

Struct NetworkStore 

Source
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

Source

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/networks or ~/.config/sdkt/networks
  • macOS: ~/Library/Application Support/sdkt/networks
  • Windows: %APPDATA%\sdkt\networks
Source

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.

Source

pub fn list(&self) -> Result<Vec<NetworkProfile>, StorageError>

List all network profiles.

Source

pub fn get(&self, name: &str) -> Result<NetworkProfile, StorageError>

Get a specific network profile by name.

Source

pub fn add(&self, profile: NetworkProfile) -> Result<(), StorageError>

Add or update a network profile.

Source

pub fn remove(&self, name: &str) -> Result<(), StorageError>

Remove a network profile.

Source

pub fn exists(&self, name: &str) -> bool

Check if a profile exists.

Source

pub fn as_map(&self) -> Result<HashMap<String, NetworkProfile>, StorageError>

Get all profiles as a map keyed by profile name.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more