Trait Callbacks

Source
pub trait Callbacks {
    // Required methods
    fn extension(&self) -> &'static str;
    fn generate_files(
        &mut self,
        generator: Generator<'_>,
    ) -> HashMap<String, String>;
    fn encode(&mut self, s: &mut String, events: Vec<Event<'_>>);

    // Provided methods
    fn start_method(
        &mut self,
        _s: &mut String,
        _resolver: &Resolver,
        _method: &Method,
    ) { ... }
    fn start_property(
        &mut self,
        _s: &mut String,
        _resolver: &Resolver,
        _property: &Property,
    ) { ... }
}
Expand description

Callbacks to encode markdown input in a given format.

This trait should be implemented if you want to make your own backend.

Required Methods§

Source

fn extension(&self) -> &'static str

File extension for the files generated by this callback.

Source

fn generate_files( &mut self, generator: Generator<'_>, ) -> HashMap<String, String>

Drive the generation process.

This returns a map from file names (relative to the output directory) to their contents.

You can find inspiration about how to implement this in the source code, for example in src/backend/html.rs.

Source

fn encode(&mut self, s: &mut String, events: Vec<Event<'_>>)

Encode the stream of events in s.

Provided Methods§

Source

fn start_method( &mut self, _s: &mut String, _resolver: &Resolver, _method: &Method, )

Called before encoding each method.

Default: does nothing

Source

fn start_property( &mut self, _s: &mut String, _resolver: &Resolver, _property: &Property, )

Called before encoding each property.

Default: does nothing

Implementations§

Source§

impl dyn Callbacks

Source

pub fn start_method_default( &mut self, s: &mut String, property: &Resolver, method: &Method, )

Default start_method implementation, implemented on dyn Callbacks to avoid code duplication.

This will create a level 3 header that looks like (in markdown):

### <a id="func-name"></a>func name(arg1: [type](link), ...) -> [type](link)
________

With appropriate linking.

Source

pub fn start_property_default( &mut self, s: &mut String, resolver: &Resolver, property: &Property, )

Default start_property implementation, implemented on dyn Callbacks to avoid code duplication.

This will create a level 3 header that looks like (in markdown):

### <a id="property-name"></a> name: [type](link)
________

With appropriate linking.

Trait Implementations§

Source§

impl Debug for dyn Callbacks

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Implementors§