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 normalize(self, op: impl Normalize) -> Self
👎Deprecated since 0.5.11: Replaced with Normalize::normalize
pub fn normalize(self, op: impl Normalize) -> Self
Normalize::normalize
Post-process text
See utils
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 PartialEq for Data
impl PartialEq for Data
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