Struct cargo_fixture::FixtureClient

source ·
pub struct FixtureClient { /* private fields */ }
Expand description

An RPC client used from fixture code.

An instance is created using FixtureClient::connect().

Implementations§

source§

impl FixtureClient

source

pub async fn connect() -> Result<Self>

Connect to the parent cargo fixture process.

source

pub async fn set_env_var( &mut self, name: impl Into<String>, value: impl Into<String> ) -> Result<()>

Request that an environment variable be set for cargo test.

source

pub async fn set_env_vars( &mut self, vars: impl IntoIterator<Item = (impl Into<String>, impl Into<String>)> ) -> Result<()>

Request that multiple environment variables be set for cargo test.

source

pub async fn set_extra_cargo_test_args( &mut self, args: impl IntoIterator<Item = impl Into<String>> ) -> Result<()>

Set additional CLI arguments to be passed to cargo test.

No that these are arguments intended for the cargo test command itself, to pass arguments to the test binary, such as --nocapture or similar, use set_extra_test_binary_args().

source

pub async fn set_extra_test_binary_args( &mut self, args: impl IntoIterator<Item = impl Into<String>> ) -> Result<()>

Set additional CLI arguments to be passed to the test binary.

When using CLI, these are usually passed via cargo using the -- syntax, i.e. cargo test -- args

source

pub async fn set_value( &mut self, key: impl Into<String>, value: impl Serialize ) -> Result<()>

Set a value in cargo fixture’s in-memory K-V storage.

The value can be any serde-serializable value. After set, it can be retrieved by the test code.

The K-V store internally uses JSON representation.

source

pub async fn set_exec( &mut self, exec: impl IntoIterator<Item = impl Into<String>> ) -> Result<()>

Replace the testing program to be executed to a custom one, along with arguments (if any).

This will make cargo fixture run the provided program instead of the usual cargo test invocation.

source

pub async fn ready(&mut self) -> Result<bool>

Signal to cargo fixture that the fixture is ready, starting the test run.

This will by default run cargo test and return back a bool success status, once the test run is complete. Note that it may take an arbitrarily long time.

Auto Trait Implementations§

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<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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.