pub struct DynamicQueryRequest {
pub request_type: DynamicQueryRequestType,
pub query_name: Option<String>,
pub query: BatchQuery,
pub parameters: Option<BTreeMap<String, DynamicQueryValue>>,
pub parameter_types: Option<BTreeMap<String, QueryParamType>>,
}Expand description
Full JSON payload accepted by the gateway dynamic query route.
Fields§
§request_type: DynamicQueryRequestTypeWhether the inline query should execute as a read or write.
query_name: Option<String>Optional query name used by gateway logs and slow-query diagnostics.
query: BatchQueryInline query AST payload.
parameters: Option<BTreeMap<String, DynamicQueryValue>>Runtime parameters forwarded to the query engine.
parameter_types: Option<BTreeMap<String, QueryParamType>>Optional parameter schema used by runtimes to coerce typed inputs.
Implementations§
Source§impl DynamicQueryRequest
impl DynamicQueryRequest
Sourcepub fn write(query: WriteBatch) -> Self
pub fn write(query: WriteBatch) -> Self
Create a dynamic request payload for a write batch.
Sourcepub fn insert_parameter_value(
&mut self,
name: impl Into<String>,
value: DynamicQueryValue,
)
pub fn insert_parameter_value( &mut self, name: impl Into<String>, value: DynamicQueryValue, )
Insert a named parameter value into the request payload.
Examples found in repository?
93fn with_params(
94 mut request: DynamicQueryRequest,
95 values: Vec<(&str, DynamicQueryValue)>,
96 types: Vec<(&str, QueryParamType)>,
97) -> DynamicQueryRequest {
98 for (name, value) in values {
99 request.insert_parameter_value(name, value);
100 }
101 for (name, ty) in types {
102 request.insert_parameter_type(name, ty);
103 }
104 request
105}Sourcepub fn insert_parameter_type(
&mut self,
name: impl Into<String>,
ty: QueryParamType,
)
pub fn insert_parameter_type( &mut self, name: impl Into<String>, ty: QueryParamType, )
Insert a named parameter type into the request payload.
Examples found in repository?
93fn with_params(
94 mut request: DynamicQueryRequest,
95 values: Vec<(&str, DynamicQueryValue)>,
96 types: Vec<(&str, QueryParamType)>,
97) -> DynamicQueryRequest {
98 for (name, value) in values {
99 request.insert_parameter_value(name, value);
100 }
101 for (name, ty) in types {
102 request.insert_parameter_type(name, ty);
103 }
104 request
105}Sourcepub fn set_query_name(&mut self, name: impl Into<String>)
pub fn set_query_name(&mut self, name: impl Into<String>)
Set the query name used by gateway logs and slow-query diagnostics.
Sourcepub fn clear_query_name(&mut self)
pub fn clear_query_name(&mut self)
Clear the query name so JSON serialization emits query_name: null.
Sourcepub fn with_parameter_value(
self,
name: impl Into<String>,
value: DynamicQueryValue,
) -> Self
pub fn with_parameter_value( self, name: impl Into<String>, value: DynamicQueryValue, ) -> Self
Insert a named parameter value and return the updated request.
Sourcepub fn with_parameter_type(
self,
name: impl Into<String>,
ty: QueryParamType,
) -> Self
pub fn with_parameter_type( self, name: impl Into<String>, ty: QueryParamType, ) -> Self
Insert a named parameter type and return the updated request.
Sourcepub fn with_query_name(self, name: impl Into<String>) -> Self
pub fn with_query_name(self, name: impl Into<String>) -> Self
Set the query name and return the updated request.
Sourcepub fn to_json_bytes(&self) -> Result<Vec<u8>, DynamicQueryError>
pub fn to_json_bytes(&self) -> Result<Vec<u8>, DynamicQueryError>
Serialize the request payload to JSON bytes.
Sourcepub fn to_json_string(&self) -> Result<String, DynamicQueryError>
pub fn to_json_string(&self) -> Result<String, DynamicQueryError>
Serialize the request payload to a JSON string.
Examples found in repository?
15fn main() -> Result<(), Box<dyn std::error::Error>> {
16 let out = env::args()
17 .nth(1)
18 .unwrap_or_else(|| "tests/parity/generated/rust".to_string());
19 let out = Path::new(&out);
20 reset_dir(&out.join("runtime"))?;
21 reset_dir(&out.join("json-only"))?;
22
23 let mut fixtures = runtime_fixtures();
24 fixtures.extend(node_permutation_fixtures());
25 fixtures.extend(json_only_fixtures());
26
27 for fixture in fixtures {
28 let path = out
29 .join(fixture.bucket)
30 .join(format!("{}.json", fixture.name));
31 fs::write(path, fixture.request.to_json_string()?)?;
32 }
33
34 Ok(())
35}Trait Implementations§
Source§impl Clone for DynamicQueryRequest
impl Clone for DynamicQueryRequest
Source§fn clone(&self) -> DynamicQueryRequest
fn clone(&self) -> DynamicQueryRequest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DynamicQueryRequest
impl Debug for DynamicQueryRequest
Source§impl<'de> Deserialize<'de> for DynamicQueryRequest
impl<'de> Deserialize<'de> for DynamicQueryRequest
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>,
Source§impl PartialEq for DynamicQueryRequest
impl PartialEq for DynamicQueryRequest
Source§fn eq(&self, other: &DynamicQueryRequest) -> bool
fn eq(&self, other: &DynamicQueryRequest) -> bool
self and other values to be equal, and is used by ==.