pub trait TestDeserializeContext {
// Required methods
fn override_syntax<I>(
&mut self,
first_arg: TokenTree,
rest_of_stream: &mut I,
type_name: &str,
) -> Result<Option<String>, String>
where I: Iterator<Item = TokenTree>;
fn reverse_syntax_override(
&mut self,
json: &Value,
type_name: &str,
) -> Option<String>;
}
Expand description
A trait for extending and/or overriding the default test case syntax.
Note when creating an implementation of this trait that the
[proc_macro2::TokenStream]
considers:
- null/true/false to be
Ident
s - strings and positive numeric values (like 1 or 1.1) to be
Literal
s. - negative numeric values to be a
Punct('-')
followed by aLiteral
.
Required Methods§
Sourcefn override_syntax<I>(
&mut self,
first_arg: TokenTree,
rest_of_stream: &mut I,
type_name: &str,
) -> Result<Option<String>, String>
fn override_syntax<I>( &mut self, first_arg: TokenTree, rest_of_stream: &mut I, type_name: &str, ) -> Result<Option<String>, String>
Override the way that first_arg
is resolved to JSON.
first_arg
is the first TokenTree
of the TokenStream
.
rest_of_stream
contains a reference to the rest of the stream.
Returns Ok(Some(value)) if first_arg
has been resolved.
Returns Ok(None) if first_arg
should be resolved using the default
syntax. If returning Ok(None), the function implementation
promises not to advance rest_of_stream
.
Sourcefn reverse_syntax_override(
&mut self,
json: &Value,
type_name: &str,
) -> Option<String>
fn reverse_syntax_override( &mut self, json: &Value, type_name: &str, ) -> Option<String>
Converts json
back to the extended syntax specified by
TestDeserializeContext::override_syntax.
Returns Some(value)
if json
has been resolved.
Returns None
is json
should be resolved in the default manner.
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.