pub struct Config {
pub general: GeneralConfig,
pub storage: StorageConfig,
pub network: NetworkConfig,
pub gateway: GatewayConfig,
pub api: ApiConfig,
pub shell: ShellConfig,
}Expand description
Main configuration structure
Fields§
§general: GeneralConfigGeneral settings
storage: StorageConfigStorage settings
network: NetworkConfigNetwork settings
gateway: GatewayConfigGateway settings
api: ApiConfigAPI settings
shell: ShellConfigShell settings
Implementations§
Source§impl Config
impl Config
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Load configuration from default locations (with caching)
This method uses a global cache to avoid repeated disk reads. The config is loaded once and reused for subsequent calls.
Search order:
- .ipfrs/config.toml (current directory)
- ~/.ipfrs/config.toml (user home)
- /etc/ipfrs/config.toml (system)
Sourcepub fn load_uncached() -> Result<Self>
pub fn load_uncached() -> Result<Self>
Load configuration from default locations without caching
Use this when you need to force a fresh load (e.g., after config changes).
Search order:
- .ipfrs/config.toml (current directory)
- ~/.ipfrs/config.toml (user home)
- /etc/ipfrs/config.toml (system)
Environment variables (override config file):
- IPFRS_PATH: Data directory
- IPFRS_LOG_LEVEL: Log level
- IPFRS_API_URL: Remote API URL
- IPFRS_API_TOKEN: API authentication token
Sourcepub fn api_url(&self) -> String
pub fn api_url(&self) -> String
Get the effective API URL
Returns the remote URL if set, otherwise returns the local listen address formatted as http://address
Sourcepub fn clear_cache()
pub fn clear_cache()
Clear the cached configuration
This forces the next load() call to reload from disk.
Note: Due to OnceLock limitations, this doesn’t actually clear the cache
but is provided for API consistency. Use load_uncached() instead.
Sourcepub fn default_path() -> Result<PathBuf>
pub fn default_path() -> Result<PathBuf>
Get the default configuration file path
Returns the path to the user’s configuration file (~/.ipfrs/config.toml)
Sourcepub fn generate_default_config() -> String
pub fn generate_default_config() -> String
Generate default config file with comments
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.