pub struct ConfigManager<F: FileSystem> { /* private fields */ }Implementations§
Source§impl<F: FileSystem> ConfigManager<F>
impl<F: FileSystem> ConfigManager<F>
pub const fn with_fs(fs: F, config_dir: PathBuf) -> Self
Sourcepub fn add_spec(
&self,
name: &str,
file_path: &Path,
force: bool,
) -> Result<(), Error>
pub fn add_spec( &self, name: &str, file_path: &Path, force: bool, ) -> Result<(), Error>
Adds a new OpenAPI specification to the configuration from a local file.
§Errors
Returns an error if:
- The spec already exists and
forceis false - File I/O operations fail
- The
OpenAPIspec is invalid YAML - The spec contains unsupported features
§Panics
Panics if the spec path parent directory is None (should not happen in normal usage).
Sourcepub async fn add_spec_from_url(
&self,
name: &str,
url: &str,
force: bool,
) -> Result<(), Error>
pub async fn add_spec_from_url( &self, name: &str, url: &str, force: bool, ) -> Result<(), Error>
Adds a new OpenAPI specification to the configuration from a URL.
§Errors
Returns an error if:
- The spec already exists and
forceis false - Network requests fail
- The
OpenAPIspec is invalid YAML - The spec contains unsupported features
- Response size exceeds 10MB limit
- Request times out (30 seconds)
§Panics
Panics if the spec path parent directory is None (should not happen in normal usage).
Sourcepub async fn add_spec_auto(
&self,
name: &str,
file_or_url: &str,
force: bool,
) -> Result<(), Error>
pub async fn add_spec_auto( &self, name: &str, file_or_url: &str, force: bool, ) -> Result<(), Error>
Adds a new OpenAPI specification from either a file path or URL.
This is a convenience method that automatically detects whether the input is a URL or file path and calls the appropriate method.
§Errors
Returns an error if:
- The spec already exists and
forceis false - File I/O operations fail (for local files)
- Network requests fail (for URLs)
- The
OpenAPIspec is invalid YAML - The spec contains unsupported features
- Response size exceeds 10MB limit (for URLs)
- Request times out (for URLs)
Sourcepub fn remove_spec(&self, name: &str) -> Result<(), Error>
pub fn remove_spec(&self, name: &str) -> Result<(), Error>
Removes an API specification from the configuration.
§Errors
Returns an error if the spec does not exist or cannot be removed.
Sourcepub fn edit_spec(&self, name: &str) -> Result<(), Error>
pub fn edit_spec(&self, name: &str) -> Result<(), Error>
Opens an API specification in the default editor.
§Errors
Returns an error if:
- The spec does not exist.
- The
$EDITORenvironment variable is not set. - The editor command fails to execute.
Sourcepub fn load_global_config(&self) -> Result<GlobalConfig, Error>
pub fn load_global_config(&self) -> Result<GlobalConfig, Error>
Loads the global configuration from config.toml.
§Errors
Returns an error if the configuration file exists but cannot be read or parsed.
Sourcepub fn save_global_config(&self, config: &GlobalConfig) -> Result<(), Error>
pub fn save_global_config(&self, config: &GlobalConfig) -> Result<(), Error>
Saves the global configuration to config.toml.
§Errors
Returns an error if the configuration cannot be serialized or written.