Struct Data
pub struct Data {
pub(crate) inner: Box<DataInner>,
}Expand description
Test fixture, actual output, or expected result
This provides conveniences for tracking the intended format (binary vs text).
Fields§
§inner: Box<DataInner>Implementations§
§impl Data
§Constructors
See also
impl Data
§Constructors
See also
§impl Data
§Assertion frameworks operations
For example, see OutputAssert
impl Data
§Assertion frameworks operations
For example, see OutputAssert
pub fn try_read_from(
path: &Path,
data_format: Option<DataFormat>,
) -> Result<Data, Error>
pub fn try_read_from( path: &Path, data_format: Option<DataFormat>, ) -> Result<Data, Error>
Load expected data from a file
pub fn write_to(&self, source: &DataSource) -> Result<(), Error>
pub fn write_to(&self, source: &DataSource) -> Result<(), Error>
Overwrite a snapshot
pub fn write_to_path(&self, path: &Path) -> Result<(), Error>
pub fn write_to_path(&self, path: &Path) -> Result<(), Error>
Overwrite a snapshot
pub 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>, Error>
pub fn is(self, format: DataFormat) -> Data
pub fn is(self, format: DataFormat) -> Data
pub fn coerce_to(self, format: DataFormat) -> Data
pub fn coerce_to(self, format: DataFormat) -> Data
Convert Self to format if possible
This is generally used on actual data to make it match expected
pub fn source(&self) -> Option<&DataSource>
pub fn source(&self) -> Option<&DataSource>
Location the data came from
pub fn format(&self) -> DataFormat
pub fn format(&self) -> DataFormat
Outputs the current DataFormat of the underlying data
Trait Implementations§
§impl IntoData for &Data
impl IntoData for &Data
§fn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
§fn json_lines(self) -> Data
fn json_lines(self) -> Data
Replaced with IntoData::is_jsonlines
§fn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
§fn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
§fn against_json(self) -> Data
fn against_json(self) -> Data
§fn against_jsonlines(self) -> Data
fn against_jsonlines(self) -> Data
§impl IntoData for Data
impl IntoData for Data
§fn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
§fn json_lines(self) -> Data
fn json_lines(self) -> Data
Replaced with IntoData::is_jsonlines
§fn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
§fn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
§fn against_json(self) -> Data
fn against_json(self) -> Data
§fn against_jsonlines(self) -> Data
fn against_jsonlines(self) -> 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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes