//! Marks and adjustments which migrate into the enclosing vertical list. use super::*; use std::sync::Arc; #[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct NativeMark { pub class: u16, pub tokens: Arc<[Token]>, pub span: Span, } #[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct NativeAdjustment { pub pre: bool, pub nodes: Vec, } #[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct SplitMarks { pub first: Arc<[Token]>, pub bottom: Arc<[Token]>, } #[derive(Clone, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct PageMarks { pub top: Option>, pub first: Option>, pub bottom: Option>, } #[derive(Default)] pub(super) struct MigratingMaterial { pub pre: Vec, pub post: Vec, } /// Only top-level adjustment and mark nodes migrate during hpack. A packed /// child remains an owner until it is explicitly unboxed. pub(super) fn extract(nodes: Vec) -> (Vec, MigratingMaterial) { let mut content = Vec::with_capacity(nodes.len()); let mut adjustments = MigratingMaterial::default(); for node in nodes { match node { TextNode::Mark(mark) => adjustments.post.push(NativeVerticalNode::Mark(mark)), TextNode::Insertion(n) => adjustments.post.push(NativeVerticalNode::Insertion(n)), TextNode::Adjustment(value) if value.pre => adjustments.pre.extend(value.nodes), TextNode::Adjustment(value) => adjustments.post.extend(value.nodes), other => content.push(other), } } (content, adjustments) }