Recording

Struct Recording 

Source
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: usize

Implementations§

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.

Source

pub fn new(id: usize, server: &'a MockServer) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn save<IntoString: Into<String>>( &self, scenario_name: IntoString, ) -> Result<PathBuf, Box<dyn Error>>

Synchronously saves the recording to the default directory (target/httpmock/recordings) with the scenario name.

§Parameters
  • scenario_name: A descriptive name for the scenario, which helps identify the recording file.
§Returns

Returns a Result with the PathBuf to the saved file or an error.

Source

pub async fn save_async<IntoString: Into<String>>( &self, scenario: IntoString, ) -> Result<PathBuf, Box<dyn Error>>

Asynchronously saves the recording to the default directory structured under target/httpmock/recordings.

§Parameters
  • scenario: A descriptive name for the test scenario, used in naming the saved file.
§Returns

Returns an async Result with the PathBuf of the saved file or an error.

Auto Trait Implementations§

§

impl<'a> Freeze for Recording<'a>

§

impl<'a> !RefUnwindSafe for Recording<'a>

§

impl<'a> Send for Recording<'a>

§

impl<'a> Sync for Recording<'a>

§

impl<'a> Unpin for Recording<'a>

§

impl<'a> !UnwindSafe for Recording<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,