pub struct Data { /* private fields */ }Expand description
Test fixture, actual output, or expected result
This provides conveniences for tracking the intended format (binary vs text).
Implementations§
source§impl Data
impl Data
§Constructors
See also
source§impl Data
impl Data
§Assertion frameworks operations
For example, see OutputAssert
sourcepub fn try_read_from(
path: &Path,
data_format: Option<DataFormat>,
) -> Result<Self>
pub fn try_read_from( path: &Path, data_format: Option<DataFormat>, ) -> Result<Self>
Load expected data from a file
sourcepub fn write_to(&self, source: &DataSource) -> Result<()>
pub fn write_to(&self, source: &DataSource) -> Result<()>
Overwrite a snapshot
sourcepub fn write_to_path(&self, path: &Path) -> Result<()>
pub fn write_to_path(&self, path: &Path) -> Result<()>
Overwrite a snapshot
sourcepub fn render(&self) -> Option<String>
pub fn render(&self) -> Option<String>
Return the underlying String
Note: this will not inspect binary data for being a valid String.
pub fn to_bytes(&self) -> Result<Vec<u8>>
sourcepub fn is(self, format: DataFormat) -> Self
pub fn is(self, format: DataFormat) -> Self
sourcepub fn coerce_to(self, format: DataFormat) -> Self
pub fn coerce_to(self, format: DataFormat) -> Self
Convert Self to format if possible
This is generally used on actual data to make it match expected
sourcepub fn source(&self) -> Option<&DataSource>
pub fn source(&self) -> Option<&DataSource>
Location the data came from
sourcepub fn format(&self) -> DataFormat
pub fn format(&self) -> DataFormat
Outputs the current DataFormat of the underlying data
Trait Implementations§
source§impl IntoData for &Data
impl IntoData for &Data
source§fn json(self) -> Data
fn json(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonAvailable on crate feature
json only.source§fn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
Available on crate feature
json only.source§fn json_lines(self) -> Data
fn json_lines(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonlinesAvailable on crate feature
json only.source§fn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
Available on crate feature
term-svg only.Initialize as Term SVG Read more
source§fn term_svg(self) -> Data
fn term_svg(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_termsvgAvailable on crate feature
term-svg only.source§fn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
Override the type this snapshot will be compared against Read more
source§fn against_json(self) -> Data
fn against_json(self) -> Data
Available on crate feature
json only.source§impl IntoData for Data
impl IntoData for Data
source§fn json(self) -> Data
fn json(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonAvailable on crate feature
json only.source§fn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
Available on crate feature
json only.source§fn json_lines(self) -> Data
fn json_lines(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonlinesAvailable on crate feature
json only.source§fn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
Available on crate feature
term-svg only.Initialize as Term SVG Read more
source§fn term_svg(self) -> Data
fn term_svg(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_termsvgAvailable on crate feature
term-svg only.source§fn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
Override the type this snapshot will be compared against Read more
source§fn against_json(self) -> Data
fn against_json(self) -> Data
Available on crate feature
json only.impl Eq for Data
Auto Trait Implementations§
impl Freeze for Data
impl RefUnwindSafe for Data
impl Send for Data
impl Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)