pub struct TestData<T> {
pub input: T,
}
Expand description
Test data for generic loading of JSON data files.
Fields§
§input: T
Input data read from JSON file.
Implementations§
Source§impl<T: DeserializeOwned> TestData<T>
impl<T: DeserializeOwned> TestData<T>
Sourcepub fn new(default_input: T) -> Self
pub fn new(default_input: T) -> Self
Create a new instance of TestData
with the given input data.
If the TEST_DATA_PATH
environment variable is set, it reads the JSON file from the path,
otherwise (or if it fails) it uses the default input data.
§Arguments
default_input
- The default input data to use if the JSON file is not found or fails to read.
§Returns
A new instance of TestData
with the input data read from the JSON file or the default input data.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for TestData<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for TestData<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for TestData<T>where
T: Freeze,
impl<T> RefUnwindSafe for TestData<T>where
T: RefUnwindSafe,
impl<T> Send for TestData<T>where
T: Send,
impl<T> Sync for TestData<T>where
T: Sync,
impl<T> Unpin for TestData<T>where
T: Unpin,
impl<T> UnwindSafe for TestData<T>where
T: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
type Err = Infallible
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Err>
Creates a shared type from an unshared type.