pub struct Project { /* private fields */ }
Implementations§
Source§impl Project
impl Project
Sourcepub fn path(&self) -> &Path
pub fn path(&self) -> &Path
Gets the std::path::Path
for the Project
’s temporary directory.
Sourcepub fn new_file<P: AsRef<Path>>(
&mut self,
path: P,
contents: &str,
) -> Result<()>
pub fn new_file<P: AsRef<Path>>( &mut self, path: P, contents: &str, ) -> Result<()>
Creates a new file with a relative path to the project’s directory.
path
gets redirected to the project’s real path (temporary and unknown).
Sourcepub fn check_file<P: AsRef<Path>>(&self, path: P, contents: &str) -> Result<()>
pub fn check_file<P: AsRef<Path>>(&self, path: P, contents: &str) -> Result<()>
Checks that the contents of a file are correct. It will panic if they aren’t, and show the differences if the feature pretty_assertions
is enabled
path
gets redirected to the project’s real path (temporary and unknown)
§Panics
Will panic if the contents of the file at path aren’t encoded as UTF-8
Sourcepub fn command<I, S>(&self, args: I) -> Result<Output>
pub fn command<I, S>(&self, args: I) -> Result<Output>
Executes a command relative to the project’s directory
Sourcepub fn is_bin<P: AsRef<Path>>(&self, path: P) -> bool
pub fn is_bin<P: AsRef<Path>>(&self, path: P) -> bool
Checks the file signature of a file and returns true
if the file in that path is an executable.
The checked file signatures are the following, if the file’s signature is any of the following, the function will return true
.
4D 5A
- DOS MZ executable and descendants | (.exe, .scr, .sys, .dll, .fon, .cpl, .iec, .ime, .rs, .tsp, .mz)
5A 4D
- DOS ZM executable and descendants, rare | (.exe)
7F 45 4C 46
- ELF files
64 65 78 0A 30 33 35 00
4A 6F 79 21
- Preferred Executable Format
00 00 03 F3
- Amiga Hunk executable file
Sourcepub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q)
pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(&self, src: P, dst: Q)
Creates a symbolic link, both paths are relative to the temporary project’s path.
§Panics
This function will panic if the OS can’t create a system between the two paths.
Sourcepub fn clean_env(&self, prefix: &str)
pub fn clean_env(&self, prefix: &str)
Cleans your environment used in the working directory (i.e. removing all environment variables that start with a prefix).
(Note that “localized” environment variables are taken into account)
§Panics
This function will panic if it couldn’t get the current working directory, or; it can’t set the current working directory to the temporary project’s path, or; it can’t set the current working directory to the original working directory.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Project
impl RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl UnwindSafe for Project
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);