pub trait IntoData: Sized {
Show 13 methods
// Required method
fn into_data(self) -> Data;
// Provided methods
fn raw(self) -> Data { ... }
fn unordered(self) -> Data { ... }
fn is(self, format: DataFormat) -> Data { ... }
fn is_json(self) -> Data { ... }
fn json(self) -> Data { ... }
fn is_jsonlines(self) -> Data { ... }
fn json_lines(self) -> Data { ... }
fn is_termsvg(self) -> Data { ... }
fn term_svg(self) -> Data { ... }
fn against(self, format: DataFormat) -> Data { ... }
fn against_json(self) -> Data { ... }
fn against_jsonlines(self) -> Data { ... }
}Expand description
Convert to Data with modifiers for expected data
Required Methods§
Provided Methods§
Sourcefn unordered(self) -> Data
fn unordered(self) -> Data
Treat lines and json arrays as unordered
§Examples
use snapbox::prelude::*;
use snapbox::str;
use snapbox::assert_data_eq;
let actual = str![[r#"["world", "hello"]"#]]
.is(snapbox::data::DataFormat::Json)
.unordered();
let expected = str![[r#"["hello", "world"]"#]]
.is(snapbox::data::DataFormat::Json)
.unordered();
assert_data_eq!(actual, expected);Sourcefn is(self, format: DataFormat) -> Data
fn is(self, format: DataFormat) -> Data
fn json(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonSourcefn is_jsonlines(self) -> Data
fn is_jsonlines(self) -> Data
fn json_lines(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_jsonlinesSourcefn is_termsvg(self) -> Data
fn is_termsvg(self) -> Data
Initialize as Term SVG
This is generally used for expected data
fn term_svg(self) -> Data
👎Deprecated since 0.6.13: Replaced with
IntoData::is_termsvgSourcefn against(self, format: DataFormat) -> Data
fn against(self, format: DataFormat) -> Data
Override the type this snapshot will be compared against
Normally, the actual data is coerced to IntoData::is.
This allows overriding that so you can store your snapshot in a more readable, diffable
format.
§Examples
use snapbox::prelude::*;
use snapbox::str;
let expected = str![[r#"{"hello": "world"}"#]]
.against(snapbox::data::DataFormat::JsonLines);Sourcefn against_json(self) -> Data
fn against_json(self) -> Data
Sourcefn against_jsonlines(self) -> Data
fn against_jsonlines(self) -> Data
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.