pub struct CollectionManager { /* private fields */ }Expand description
Manager for API collections
Provides methods for CRUD operations on collections and endpoints.
Implementations§
Source§impl CollectionManager
impl CollectionManager
Sourcepub fn new(file_path: Option<String>, in_memory: bool) -> Self
pub fn new(file_path: Option<String>, in_memory: bool) -> Self
Create a new CollectionManager
§Arguments
file_path- Optional custom file path. If None, uses default location.
Sourcepub fn get_file_path(&self) -> String
pub fn get_file_path(&self) -> String
Get the file path being used
Sourcepub async fn get_collections(&self) -> Vec<Collection>
pub async fn get_collections(&self) -> Vec<Collection>
Get loaded collections
Sourcepub async fn get_collection(
&self,
name: &str,
) -> CollectionResult<Option<Collection>>
pub async fn get_collection( &self, name: &str, ) -> CollectionResult<Option<Collection>>
Get a specific Collection by name
Sourcepub async fn get_endpoint(
&self,
col_name: &str,
ep_name: &str,
) -> CollectionResult<Option<Request>>
pub async fn get_endpoint( &self, col_name: &str, ep_name: &str, ) -> CollectionResult<Option<Request>>
Get a specific Endpoint by collection name and request name
Sourcepub async fn update_add_collection(
&self,
updated: Collection,
) -> CollectionResult<()>
pub async fn update_add_collection( &self, updated: Collection, ) -> CollectionResult<()>
Update an existing collection or add a new one
Sourcepub async fn update_add_request(
&self,
col_name: &str,
ep_name: &str,
updated: Request,
) -> CollectionResult<()>
pub async fn update_add_request( &self, col_name: &str, ep_name: &str, updated: Request, ) -> CollectionResult<()>
Update an existing request within a collection or add a new one
Sourcepub async fn delete_collection(&self, name: &str) -> CollectionResult<()>
pub async fn delete_collection(&self, name: &str) -> CollectionResult<()>
Delete a collection
Sourcepub async fn save_loaded_collections(self) -> CollectionResult<()>
pub async fn save_loaded_collections(self) -> CollectionResult<()>
Save collections to the storage file
Source§impl CollectionManager
impl CollectionManager
Sourcepub async fn add_collection(
&self,
name: &str,
url: &str,
headers: Vec<(String, String)>,
) -> CollectionResult<()>
pub async fn add_collection( &self, name: &str, url: &str, headers: Vec<(String, String)>, ) -> CollectionResult<()>
Add a new collection
If a collection with the same name exists, it will be updated.
Sourcepub async fn copy_collection(
&self,
name: &str,
new_name: &str,
) -> CollectionResult<()>
pub async fn copy_collection( &self, name: &str, new_name: &str, ) -> CollectionResult<()>
Copy a collection to a new name
Source§impl CollectionManager
impl CollectionManager
Sourcepub async fn get_endpoint_url(
&self,
col_name: &str,
ep_name: &str,
) -> CollectionResult<String>
pub async fn get_endpoint_url( &self, col_name: &str, ep_name: &str, ) -> CollectionResult<String>
Get the full URL for an endpoint (base URL + endpoint path)
Sourcepub async fn get_endpoint_headers(
&self,
collection: &str,
endpoint: &str,
) -> Vec<(String, String)>
pub async fn get_endpoint_headers( &self, collection: &str, endpoint: &str, ) -> Vec<(String, String)>
Get merged headers for an endpoint (collection headers + endpoint headers)
Sourcepub async fn add_endpoint(
&self,
col_name: &str,
ep_name: &str,
path: &str,
method: Method,
headers: Vec<(String, String)>,
body: Option<String>,
) -> CollectionResult<()>
pub async fn add_endpoint( &self, col_name: &str, ep_name: &str, path: &str, method: Method, headers: Vec<(String, String)>, body: Option<String>, ) -> CollectionResult<()>
Add an endpoint to a collection
If an endpoint with the same name exists, it will be updated.
Sourcepub async fn update_endpoint(
&self,
col_name: &str,
ep_name: &str,
path: Option<&str>,
headers: Option<Vec<(String, String)>>,
body: Option<String>,
) -> CollectionResult<()>
pub async fn update_endpoint( &self, col_name: &str, ep_name: &str, path: Option<&str>, headers: Option<Vec<(String, String)>>, body: Option<String>, ) -> CollectionResult<()>
Update an endpoint in a collection
Sourcepub async fn copy_endpoint(
&self,
col_name: &str,
ep_name: &str,
new_name: &str,
to_col: Option<&str>,
) -> CollectionResult<()>
pub async fn copy_endpoint( &self, col_name: &str, ep_name: &str, new_name: &str, to_col: Option<&str>, ) -> CollectionResult<()>
Copy an endpoint within the same collection or to another collection
Sourcepub async fn delete_endpoint(
&self,
collection: &str,
endpoint: &str,
) -> CollectionResult<()>
pub async fn delete_endpoint( &self, collection: &str, endpoint: &str, ) -> CollectionResult<()>
Delete an endpoint from a collection
Trait Implementations§
Source§impl Clone for CollectionManager
impl Clone for CollectionManager
Source§fn clone(&self) -> CollectionManager
fn clone(&self) -> CollectionManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more