1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use super::segments::Segments;
use crate::core::rules::context::RuleContext;
pub struct FunctionalContext<'a> {
context: RuleContext<'a>,
}
impl<'a> FunctionalContext<'a> {
pub fn new(context: RuleContext<'a>) -> FunctionalContext {
FunctionalContext { context }
}
pub fn segment(&self) -> Segments {
Segments::new(self.context.segment.clone(), self.context.templated_file.clone())
}
// pub fn parent_stack(&self) -> Segments {
// // Assuming `Segments::from_slice` is a method to create Segments from a
// slice Segments::from_slice(&self.context.parent_stack,
// self.context.templated_file) }
// pub fn siblings_pre(&self) -> Segments {
// Segments::from_slice(&self.context.siblings_pre,
// self.context.templated_file) }
pub fn siblings_post(&self) -> Segments {
Segments::from_vec(self.context.siblings_post(), self.context.templated_file.clone())
}
pub fn parent_stack(&self) -> Segments {
Segments::from_vec(self.context.parent_stack.clone(), self.context.templated_file.clone())
}
// pub fn raw_stack(&self) -> Segments {
// Segments::from_slice(&self.context.raw_stack,
// self.context.templated_file) }
// pub fn raw_segments(&self) -> Segments {
// let file_segment = &self.context.parent_stack[0];
// // Assuming `get_raw_segments` returns a slice or Vec
// Segments::from_slice(file_segment.get_raw_segments(),
// self.context.templated_file) }
}