Struct rtlola_parser::ast::Expression
source · pub struct Expression {
pub kind: ExpressionKind,
pub id: NodeId,
pub span: Span,
}Expand description
The Ast representation of a stream expression
Fields§
§kind: ExpressionKindThe kind of the root expression, e.g., stream access
id: NodeIdThe id of the node in the Ast
span: SpanThe span in the specification declaring the extend declaration
Implementations§
source§impl Expression
impl Expression
sourcepub fn parse_discrete_duration(&self) -> Result<u64, String>
pub fn parse_discrete_duration(&self) -> Result<u64, String>
Parses an expression into a duration for a discrete window ExpressionKind::DiscreteWindowAggregation
sourcepub fn parse_frequency(&self) -> Result<UOM_Frequency, String>
pub fn parse_frequency(&self) -> Result<UOM_Frequency, String>
Parses an expression into a frequency. Expression must be a positive numeric value with Hz unit.
Examples found in repository?
src/ast/conversion.rs (line 147)
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
pub fn parse_freqspec(&self) -> Result<UOM_Frequency, String> {
if let Ok(freq) = self.parse_frequency() {
Ok(freq)
} else if let Ok(period) = self.parse_duration() {
let seconds = period.get::<second>();
if seconds.is_positive() {
Ok(UOM_Frequency::new::<hertz>(seconds.inv()))
} else {
Err(format!(
"duration of periodic stream specification must be positive, found `{:#?}`",
period
))
}
} else {
Err(format!("expected frequency or duration, found `{}`", self))
}
}sourcepub fn parse_freqspec(&self) -> Result<UOM_Frequency, String>
pub fn parse_freqspec(&self) -> Result<UOM_Frequency, String>
Parses a frequency annotation. Expression must either be a frequency or a duration representing the period
Trait Implementations§
source§impl Clone for Expression
impl Clone for Expression
source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a copy of the value. Read more
1.0.0 · 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 Expression
impl Debug for Expression
source§impl Display for Expression
impl Display for Expression
source§impl Hash for Expression
impl Hash for Expression
source§impl PartialEq<Expression> for Expression
impl PartialEq<Expression> for Expression
source§fn eq(&self, other: &Expression) -> bool
fn eq(&self, other: &Expression) -> bool
This method tests for
self and other values to be equal, and is used
by ==.