pub struct CollectionManager {
pub loaded_collections: Option<Vec<Collection>>,
/* private fields */
}Expand description
Manager for API collections
Provides methods for CRUD operations on collections and endpoints.
Fields§
§loaded_collections: Option<Vec<Collection>>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 fn get_collection(
&mut self,
name: &str,
) -> CollectionResult<&mut Collection>
pub fn get_collection( &mut self, name: &str, ) -> CollectionResult<&mut Collection>
Get a specific collection by name
Sourcepub fn get_collection_imutable(
&self,
name: &str,
) -> CollectionResult<&Collection>
pub fn get_collection_imutable( &self, name: &str, ) -> CollectionResult<&Collection>
Get a specific collection imutable by name
Sourcepub fn get_endpoint(
&mut self,
col_name: &str,
ep_name: &str,
) -> CollectionResult<Request>
pub fn get_endpoint( &mut self, col_name: &str, ep_name: &str, ) -> CollectionResult<Request>
Get a specific endpoint from a collection
Sourcepub fn save_collections(self) -> CollectionResult<()>
pub fn save_collections(self) -> CollectionResult<()>
Save collections to the storage file
Source§impl CollectionManager
impl CollectionManager
Sourcepub fn add_collection(
self,
name: &str,
url: &str,
headers: Vec<(String, String)>,
) -> CollectionResult<()>
pub 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 fn delete_collection(self, name: &str) -> CollectionResult<()>
pub fn delete_collection(self, name: &str) -> CollectionResult<()>
Delete a collection
Sourcepub fn update_collection(
self,
name: &str,
url: Option<&str>,
headers: Option<Vec<(String, String)>>,
) -> CollectionResult<()>
pub fn update_collection( self, name: &str, url: Option<&str>, headers: Option<Vec<(String, String)>>, ) -> CollectionResult<()>
Update a collection
Sourcepub fn copy_collection(self, name: &str, new_name: &str) -> CollectionResult<()>
pub fn copy_collection(self, name: &str, new_name: &str) -> CollectionResult<()>
Copy a collection to a new name
Source§impl CollectionManager
impl CollectionManager
Sourcepub fn get_endpoint_url(
self,
collection: &str,
endpoint: &str,
) -> CollectionResult<String>
pub fn get_endpoint_url( self, collection: &str, endpoint: &str, ) -> CollectionResult<String>
Get the full URL for an endpoint (base URL + endpoint path)
Sourcepub fn get_endpoint_headers(
self,
collection: &str,
endpoint: &str,
) -> Vec<(String, String)>
pub fn get_endpoint_headers( self, collection: &str, endpoint: &str, ) -> Vec<(String, String)>
Get merged headers for an endpoint (collection headers + endpoint headers)
Sourcepub fn add_endpoint(
self,
collection: &str,
name: &str,
path: &str,
method: Method,
headers: Vec<(String, String)>,
body: Option<String>,
) -> CollectionResult<()>
pub fn add_endpoint( self, collection: &str, 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 fn update_endpoint(
self,
collection: &str,
endpoint: &str,
path: Option<&str>,
headers: Option<Vec<(String, String)>>,
body: Option<String>,
) -> CollectionResult<()>
pub fn update_endpoint( self, collection: &str, endpoint: &str, path: Option<&str>, headers: Option<Vec<(String, String)>>, body: Option<String>, ) -> CollectionResult<()>
Update an endpoint in a collection
Sourcepub fn copy_endpoint(
self,
collection: &str,
endpoint: &str,
new_name: &str,
to_collection: Option<&str>,
) -> CollectionResult<()>
pub fn copy_endpoint( self, collection: &str, endpoint: &str, new_name: &str, to_collection: Option<&str>, ) -> CollectionResult<()>
Copy an endpoint within the same collection or to another collection
Sourcepub fn delete_endpoint(
self,
collection: &str,
endpoint: &str,
) -> CollectionResult<()>
pub fn delete_endpoint( self, collection: &str, endpoint: &str, ) -> CollectionResult<()>
Delete an endpoint from a collection
Sourcepub fn list_collections(self) -> CollectionResult<Vec<Collection>>
pub fn list_collections(self) -> CollectionResult<Vec<Collection>>
List all collections
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