pub struct QueryTemplate {
pub id: &'static str,
pub description: &'static str,
pub template: &'static str,
pub params: &'static [Param],
pub kind: TemplateKind,
pub example: &'static [&'static str],
}Expand description
A query template for oracle-friendly trace generation.
Fields§
§id: &'static strUnique template identifier
description: &'static strHuman-readable template description
template: &'static strThe template string with {PLACEHOLDERS}
params: &'static [Param]Parameters this template expects
kind: TemplateKindExpected oracle kind
example: &'static [&'static str]Example parameter values
Implementations§
Source§impl QueryTemplate
impl QueryTemplate
Sourcepub fn render(&self, values: &[&str]) -> String
pub fn render(&self, values: &[&str]) -> String
Render this template with the given parameter values.
Sourcepub fn all() -> &'static [QueryTemplate]
pub fn all() -> &'static [QueryTemplate]
Get all defined templates.
Sourcepub fn by_kind(
kind: TemplateKind,
) -> impl Iterator<Item = &'static QueryTemplate>
pub fn by_kind( kind: TemplateKind, ) -> impl Iterator<Item = &'static QueryTemplate>
Get templates by kind.
Sourcepub fn find(id: &str) -> Option<&'static QueryTemplate>
pub fn find(id: &str) -> Option<&'static QueryTemplate>
Find a template by ID.
Sourcepub fn random_example(&self) -> String
pub fn random_example(&self) -> String
Generate a random example query (for testing).
Source§impl QueryTemplate
impl QueryTemplate
Sourcepub fn iter_kind(kind: TemplateKind) -> TemplateIter
pub fn iter_kind(kind: TemplateKind) -> TemplateIter
Iterate over templates of a specific kind.
Trait Implementations§
Source§impl Clone for QueryTemplate
impl Clone for QueryTemplate
Source§fn clone(&self) -> QueryTemplate
fn clone(&self) -> QueryTemplate
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueryTemplate
impl Debug for QueryTemplate
Source§impl Deserialize<'static> for QueryTemplate
impl Deserialize<'static> for QueryTemplate
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for QueryTemplate
impl RefUnwindSafe for QueryTemplate
impl Send for QueryTemplate
impl Sync for QueryTemplate
impl Unpin for QueryTemplate
impl UnsafeUnpin for QueryTemplate
impl UnwindSafe for QueryTemplate
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