pub struct Datadir { /* private fields */ }
Expand description

The Datadir is the context type which provides a directory for each scenario and allows for the creation and testing of files within that directory.

A few steps are provided as part of this step library, though in reality the majority of steps which interact with the data directory are in the files step library, and commands which interact with stuff in here are in the runcmd step library.

Implementations§

source§

impl Datadir

source

pub fn base_path(&self) -> &Path

Retrieve the base data directory path which can be used to store files etc. for this step.

This is used by steps wishing to manipulate the content of the data directory.

source

pub fn canonicalise_filename<S: AsRef<Path>>( &self, subpath: S ) -> Result<PathBuf, StepError>

Canonicalise a subpath into this dir

This step safely joins the base path to the given subpath. This ensures that, for example, the subpath is relative, does not contain .. elements, etc.

source

pub fn open_write<S: AsRef<Path>>(&self, subpath: S) -> Result<File, StepError>

Open a file for writing

This is a convenience function to open a file for writing at the given subpath.

source

pub fn open_read<S: AsRef<Path>>(&self, subpath: S) -> Result<File, StepError>

Open a file for reading

This is a convenience function to open a file for reading from the given subpath

source

pub fn create_dir_all<S: AsRef<Path>>( &self, subpath: S ) -> Result<(), StepError>

Make a directory tree

Equivalent to mkdir -p this will create the full path to the given subpath allowing subsequent step code to use that directory.

Trait Implementations§

source§

impl ContextElement for Datadir

source§

fn created(&mut self, scenario: &Scenario)

A new context element was created. Read more
source§

fn scenario_starts(&mut self) -> StepResult

Scenario starts Read more
source§

fn scenario_stops(&mut self) -> StepResult

Scenario stops Read more
source§

fn step_starts(&mut self, step_title: &str) -> StepResult

Entry to a step function Read more
source§

fn step_stops(&mut self) -> StepResult

Exit from a step function Read more
source§

impl Debug for Datadir

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Datadir

source§

fn default() -> Datadir

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.