#[derive(KRQLQuery)]
{
// Attributes available to this derive:
#[krql]
#[serde]
}
Expand description
The KRQLQuery derive macro will create two structure QC and QC_ used to serialize following the format expected by krQL.
For instance the following structure:
pub struct Test
{
pub print: Option<String>,
#[serde(rename = "return")]
pub return_value: Option<String>,
}Should be serialized as:
test:
print: "a string"
return: "an other string"But with serde, it would be serialized as: print: “a string” return: “an other string”
To solve that problem, KRQLQuery generates two structures TestQC and TestQC_. TestQC_ is a copy of Test used for serialization, and TestQC is defined as:
struct TestQC
{
test: TestQC_
}Then we can define Test with the following:
#[derive(Clone, Default, KRQLQuery)]
pub struct Test { ... }That means that Test is serialized using the TestQC class into the proper structure for krQL.
serde(…) can be used on fields
# use kdb_connection::KRQLQuery;
#[derive(Clone, Default, KRQLQuery)]
pub struct Test {
#[serde(rename="some field")]
some_field: String,
}krql(key = “…”, tag = “…”) can be used to set the krQL key, otherwise default to snake case version of the class name. While tag is passed to serde, for enums.