use crate::model::{Fragment, Schema};
use displaydoc::Display;
use std::ops::RangeBounds;
use thiserror::Error;
#[derive(Debug, Display, Error)]
pub enum ContentMatchError {
InvalidContent,
}
pub trait ContentMatch<S: Schema>: Copy {
fn match_fragment(self, fragment: &Fragment<S>) -> Option<Self> {
self.match_fragment_range(fragment, ..)
}
fn match_fragment_range<R: RangeBounds<usize>>(
self,
fragment: &Fragment<S>,
range: R,
) -> Option<Self>;
fn valid_end(self) -> bool;
fn match_type(self, r#type: S::NodeType) -> Option<Self>;
fn fill_before(
self,
_after: &Fragment<S>,
_to_end: bool,
_start_index: usize,
) -> Option<Fragment<S>> {
None
}
fn find_wrapping(self, _target: S::NodeType) -> Option<Vec<S::NodeType>> {
None
}
fn compatible(self, _other: Self) -> bool {
false
}
fn inline_content(self) -> bool {
false
}
fn edge_count(self) -> usize {
0
}
fn edge(self, _n: usize) -> Option<(S::NodeType, Self)> {
None
}
}