summaryrefslogtreecommitdiff
path: root/src/func.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-05-24 12:24:10 +0200
committerLaurenz <laurmaedje@gmail.com>2019-05-24 12:24:10 +0200
commitb3734bbc046fe7b14cff54e2dae7014a71014777 (patch)
treed80e97d9f0694cb7e7f61869a1085e64e791a5b8 /src/func.rs
parente3215fa3b92574e2087c28b1d494d397e6819236 (diff)
Restructure engine into modular layouter 🍂
Diffstat (limited to 'src/func.rs')
-rw-r--r--src/func.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/func.rs b/src/func.rs
index c90e87ad..ef5120df 100644
--- a/src/func.rs
+++ b/src/func.rs
@@ -6,7 +6,7 @@ use std::fmt::{self, Debug, Formatter};
use crate::syntax::FuncHeader;
use crate::parsing::{ParseContext, ParseResult};
-use crate::engine::{TypesetContext, TypesetResult};
+use crate::layout::{Layout, LayoutContext, LayoutResult};
/// Types that act as functions.
@@ -17,12 +17,16 @@ use crate::engine::{TypesetContext, TypesetResult};
/// The trait `FunctionBounds` is automatically implemented for types which can be
/// used as functions, that is they fulfill the bounds `Debug + PartialEq + 'static`.
pub trait Function: FunctionBounds {
- /// Parse the tokens of the context with the given header and scope into self.
+ /// Parse the header and body into this function given this context.
fn parse(header: &FuncHeader, body: Option<&str>, ctx: &ParseContext)
-> ParseResult<Self> where Self: Sized;
- /// Execute the function and optionally yield a return value.
- fn typeset(&self, ctx: &TypesetContext) -> TypesetResult<()>;
+ /// Layout this function given a context.
+ ///
+ /// Returns optionally the resulting layout and a if changes to the context
+ /// should be made new context.
+ fn layout(&self, ctx: &LayoutContext)
+ -> LayoutResult<(Option<Layout>, Option<LayoutContext>)>;
}
impl PartialEq for dyn Function {