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
sourceimpl Data
impl Data
sourcepub fn read_from(path: &Path, binary: Option<bool>) -> Result<Self, Error>
pub fn read_from(path: &Path, binary: Option<bool>) -> Result<Self, Error>
Load test data from a file
sourcepub fn replace_lines(
&mut self,
line_nums: Range<usize>,
text: &str
) -> Result<(), Error>
pub fn replace_lines(
&mut self,
line_nums: Range<usize>,
text: &str
) -> Result<(), Error>
Update an inline snapshot
sourcepub fn try_text(self) -> Self
pub fn try_text(self) -> Self
Convert from binary to text, if possible
This will do extra binary file detection if detect-encoding
feature flag is set
sourcepub fn make_text(&mut self) -> Result<(), Utf8Error>
pub fn make_text(&mut self) -> Result<(), Utf8Error>
Coerce to a string
Note: this will not do a binary-content check
sourcepub fn into_string(self) -> Result<String, Utf8Error>
pub fn into_string(self) -> Result<String, Utf8Error>
Coerce to a string
Note: this will not do a binary-content check
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Return the underlying str
Note: this will not inspect binary data for being a valid str
.
pub fn as_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Trait Implementations
impl Eq for Data
impl StructuralEq for Data
impl StructuralPartialEq for Data
Auto Trait Implementations
impl RefUnwindSafe for Data
impl Send for Data
impl Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more