pub struct Recording<'a> {
pub id: usize,
/* private fields */
}Expand description
Represents a recording of interactions (requests and responses) on a mock server. This structure is used to capture and store detailed information about the HTTP requests received by the server and the corresponding responses sent back.
The Recording structure can be especially useful in testing scenarios where
monitoring and verifying the exact behavior of HTTP interactions is necessary,
such as ensuring that a server is responding with the correct headers, body content,
and status codes in response to various requests.
Fields§
§id: usizeImplementations§
Source§impl<'a> Recording<'a>
Represents a reference to a recording of HTTP interactions on a mock server.
This struct allows for management and retrieval of recorded data, such as viewing,
exporting, and deleting the recording.
impl<'a> Recording<'a>
Represents a reference to a recording of HTTP interactions on a mock server. This struct allows for management and retrieval of recorded data, such as viewing, exporting, and deleting the recording.
pub fn new(id: usize, server: &'a MockServer) -> Self
Sourcepub fn delete(&mut self)
pub fn delete(&mut self)
Synchronously deletes the recording from the mock server. This method blocks the current thread until the deletion is completed, ensuring that the recording is fully removed before proceeding.
§Panics
Panics if the deletion fails, which can occur if the recording does not exist, or there are server connectivity issues.
Sourcepub async fn delete_async(&self)
pub async fn delete_async(&self)
Asynchronously deletes the recording from the mock server. This method allows for non-blocking operations, suitable for asynchronous environments where tasks are performed concurrently without waiting for the deletion to complete.
§Panics
Panics if the deletion fails, typically due to the recording not existing on the server or connectivity issues with the server. This method provides immediate feedback by raising a panic on such failures.
Sourcepub fn save_to<PathRef: AsRef<Path>, IntoString: Into<String>>(
&self,
dir: PathRef,
scenario_name: IntoString,
) -> Result<PathBuf, Box<dyn Error>>
pub fn save_to<PathRef: AsRef<Path>, IntoString: Into<String>>( &self, dir: PathRef, scenario_name: IntoString, ) -> Result<PathBuf, Box<dyn Error>>
Synchronously saves the recording to a specified directory with a timestamped filename. The file is named using a combination of the provided scenario name and a UNIX timestamp, formatted as YAML.
§Parameters
dir: The directory path where the file will be saved.scenario_name: A descriptive name for the scenario, used as part of the filename.
§Returns
Returns a Result containing the PathBuf of the created file, or an error if the save operation fails.
§Errors
Errors if the file cannot be written due to issues like directory permissions, unavailable disk space, or other I/O errors.
Sourcepub async fn save_to_async<PathRef: AsRef<Path>, IntoString: Into<String>>(
&self,
dir: PathRef,
scenario: IntoString,
) -> Result<PathBuf, Box<dyn Error>>
pub async fn save_to_async<PathRef: AsRef<Path>, IntoString: Into<String>>( &self, dir: PathRef, scenario: IntoString, ) -> Result<PathBuf, Box<dyn Error>>
Asynchronously saves the recording to the specified directory with a scenario-specific and timestamped filename.
§Parameters
dir: The directory path where the file will be saved.scenario: A string representing the scenario name, used as part of the filename.
§Returns
Returns an async Result with the PathBuf of the saved file or an error if unable to save.