Trait Block

Source
pub trait Block {
    type Input;
    type Node;
    type State;

    // Required method
    fn parse(
        &self,
        editor: &Editor<Self::Node, Self::State, Self::Input>,
        input: &Self::Input,
    ) -> Self::Node;

    // Provided methods
    fn hook(&self, editor: &mut Editor<Self::Node, Self::State, Self::Input>) { ... }
    fn accepts(&self, input: &Self::Input) -> bool { ... }
}
Expand description

Trait for defining blocks that process input nodes

Required Associated Types§

Required Methods§

Source

fn parse( &self, editor: &Editor<Self::Node, Self::State, Self::Input>, input: &Self::Input, ) -> Self::Node

Parses an input node and produces a node of a different type.

Provided Methods§

Source

fn hook(&self, editor: &mut Editor<Self::Node, Self::State, Self::Input>)

Called when a block is hooked into an editor.

Source

fn accepts(&self, input: &Self::Input) -> bool

Determines whether the block accepts a specific input node.

Implementors§